After a series of previous work, the GO language environment has been built. We also got a taste of most of the commands that GO offers. But there is one more thing you need to do before you can go into development: choose an IDE that works for you.

Why use an IDE

“Why should a programmer use an IDE?” is a common question in some community forums. Everyone has an opinion on whether you should use an IDE or not.

In the early days, ides were not needed for program development, which was dominated by machine code programming. Later, with the development of the computer industry, in order to further improve the efficiency of engineering development, IDE came into being.

It is important to understand that an IDE is a set of software that is easy to develop through the integration of various command toolsets. It usually helps us form a set of efficient programming habits. The ultimate goal is to improve the development efficiency of the project.

Knowing the nature of an IDE, we can make our own IDE out of a text editor like Vim or Emacs if we want to mess with it.

What functions are supported?

Whether you use an existing IDE on the market or vim’s hand-built IDE, there is always a question: what are the features involved in an IDE? The ability to edit text needs no introduction, it is the most basic function.

shortcuts

Keeping both hands on the keyboard is an important part of effective development, and to do it, we need to rely on powerful keyboard shortcuts. Ides usually have a unique set of shortcut key specifications. When used to an IDE, shortcuts may be one of the main reasons why people are reluctant to switch.

Code highlighting

Code highlighting involves variables, function definitions, classes, constants, special symbols, keywords, and so on. Code highlighting improves the code reading experience, uses different color schemes for different syntax, and reduces the chance of code errors. In addition, ides generally support custom color matching, which can be set up by personal preference.

Code formatting

In order to facilitate team development, uniform code specifications are usually established prior to project development. Established specifications need to be followed, and ides generally support code formatting to help us achieve our goals more easily. It should be noted that, unlike GO, many programming languages do not have gofmt-like commands and code specifications are varied.

Code hinting

The IDE code prompt can quickly produce a list of suggestions based on input, such as parameter information, member lists, code snippets, and so on. Some ides may even analyze a user’s history of actions in order to give more accurate hints. It feels like this is already a small recommendation system.

Navigation jump

Large projects usually have a large amount of code and file involved. In development, we often need to jump between variables, functions, classes, and so on. The most inconvenient way, we can use the keyboard arrow keys or mouse to switch. Ides generally implement ways to jump quickly between variables, type definitions, function definitions, and files.

Code debugging

In most cases, code debugging can be done by printing functions. But with the debugging capabilities provided by systematic tools, we can deal with all kinds of complex scenarios. Debugging tools usually support various breakpoint debugging capabilities, variable observation, and so on.

Build to compile

The most commonly used build tool for Linux is the Makefile, and previously C/C++ was developed with make. But some language projects can be complicated to build with, such as Java. The IDE’s build-compile feature makes it easy to generate object files. Compilation functions usually use the language’s native compiler, for example, GO uses the GO build command.

Other features

Of course, there are many other capabilities that an IDE may have, such as code refactoring, file history, locale management, database management, and so on. As long as it is possible to think of functions, basic can be integrated in, now the IDE has been completely beyond the scope of the traditional IDE.

What ides are available for GO

In 2019, GO has been in development for a decade. Many ides that can be used by the GO language have emerged during this time, and it would be impractical to cover all of them in detail. Next, I’ll highlight a few ides that I know a lot about.

Goland

Goland, the commercial company JetBrains launched the Go integrated development environment in the last two years, and it is truly powerful.

I believe many programs have used their IDE, such as Intellj IDEA of Java, PHPStorm of PHP, PyCharm of Python, CLion of C++, WebStorm of front-end, etc. With JetBrains’ IDE, we can enjoy its excellent out-of-the-box experience and the plugin system JetBrains has accumulated over a decade.

A few years ago, before Goland was released, if we wanted to use JetBrain’s IDE for GO development, we needed the plug-in support it provided. These plug-ins seem to have been removed since Goland’s release.

I have to admit, Goland’s functionality is pretty darn good. However, there are a few things I would like to make fun of. First of all, Jetbrians’ ides have the problem of lag, which causes serious resource consumption. Although some big players offer optimizations, they still don’t compare with other ides.

Goland out of the box, so that it has few problems, there is really not much to introduce, pack up the basic can be opened dry!

VS Code

Developed by Microsoft a powerful modern lightweight code editor IDE, free open source. With its powerful plug-in extension capabilities, VS Code supports project development in almost all major languages. Without exception, GO is one of them.

I didn’t try VS Code because I was a geek. It’s because JetBrains’ IDE often gets stuck and it often switches between languages. Launching multiple Jetbrains ides at once can be painful.

To add GO capabilities to VS Code, just install a plug-in, the address of the plug-in. During installation, you may encounter some problems, such as network download failure when installing some dependency packages. I won’t talk about the reason, we all understand. Still, the problem has to be solved.

Give me a concrete example! In GO plug-in, we will install a package through GO get golang.org/x/tools/xxx, at this time, there is a high probability of network connection error. We can find the corresponding repository from Github, golang/tools, and then use git command to download, put in the directory specified by GOPATH, and then install.

Finally, as an aside, VS Code was developed using Electron, which is an open source library for building cross-platform desktop applications using HTML, CSS and JavaScript, a combination of NodeJS and Chromium. Therefore, with VS Code, we can implement a lot of weird plug-ins, such as the ones below.

GitHub Daily: with these VSCode plugins, it’s not a dream

Vim GO

On closer inspection, Vim is supposed to be a text editor, but it has a lot of capabilities that shouldn’t be in a text editor, such as word completion, Ctags jump, window splitting, crashed file recovery, file diff, over 400 text highlighting, and more. Most importantly, Vim has its own scripting language, which makes it possible to extend its capabilities through plug-ins.

Extending Vim into a GO IDE for your own use required a lot of complex configuration and scripting, as well as the interplay of various plug-ins to achieve our goal. Common IDE functions, such as those described earlier, are configured and implemented in VIM one by one.

GO vim environment construction, need to use a very important plug-in, VIM-Go. It is provided by foreign developers, and there are his shared videos on YouTube, you can check them out if you are interested. Vim-go provides a variety of functions such as code compilation, execution, testing, code refactoring, error notification, and more. For details, see the ViM-Go tutorial.

To be clear, although Vim supports plug-in extensions, it is still very difficult to integrate the VS Code experience. I don’t know if that’s possible, but if it is, it’s going to be very difficult. At present, I am trying to configure the GO development environment with Vim. The effect picture is as follows. Some functions are not perfect yet. When mature, you can write an article, from simple to deep to introduce you.

Currently, I use these three ides mainly. Goland is mainly used for work, while VSC and Vim are used for daily use. Of course, there are many other ides out there, and I’ll cover them briefly below, but since I haven’t used them that much, it’s hard to get a sense of experience.

Sublime Text

I started with VS Code and felt its usage habits were similar to Sublime. Sublime, however, is said to be a powerful text editor, and its encoding capabilities are extended by plug-ins. GoSublime is a plug-in that extends GO functionality for Sublime.

LiteIDE is a lightweight IDE that I heard was developed by the Chinese. It was probably popular before Goland came along. Or maybe they are ignorant and don’t know how many people still use it.

Eclipse, the open source IDE, has been popular for many years, has a wealth of resources and fans, and is probably the favorite IDE for Java development. GoEclise is Eclipse’s plugin for Goland. According to Github, the project hasn’t been updated in a while.

Atom, like VS Code, is based on Node-WebKit, or Electron. Github is an open source text editor from Github. Go-plus is a plug-in developed by Atom for Golang

conclusion

This article introduces some of the history of ides, starting with why they are used. It also summarizes what a basic IDE typically provides. Just knowing these things can help us use them better in the future. Finally, several popular IDES are introduced and their advantages and disadvantages are analyzed as far as I can.