When LEARNING Golang recently, I encountered the problem of choosing an IDE. In fact, there are only three options: GoLand: A Clever IDE to Go by JetBrains, Visual Studio Code Go IDE, and other tools, including various editor Golang plug-ins or extensions to general-purpose IDE tools. This article focuses on the Visual Studio Code Go IDE, which is a free and well-designed tool worth checking out.
The installation
Visual Studio Code Go IDE has more than 3 million downloads and seems to be a favorite. Installation is also relatively simple
-
Navigate to the Extensions pane (Ctrl+Shift+X). Search for “Go” and install this extension (the publisher ID is
golang.Go
) -
Install the assistive tool, and activate the Command Palette(menu View/Command Palette… , or Shift+Command+P) and then Run Go: Install/Update Tools
After execution, opening the go language source code activates go mode, and basic tools are available
usage
Md at master · golang/vscode-go, the most commonly used code browsing, navigation, jump support, as well as code highlighting, formatting, basically meet the simple development of use.
More practical functions:
- Unit test integration, can generate unit test framework, fast execution of unit test cases, support run and DEBUG modes, quick switching between code and test cases
- Take a quick look at definitions and references
- See the code outline, which is useful for large code files
- Built-in common code snippets, while supporting custom code snippets
- Organize imports
- Refactoring support: rename
- Automatically and quickly Generate code structures, such as Go: Add Tags to Struct Fields, Go: Generate Interface Stubs, and Go: Fill Struct
- Easy-to-use error tips: including compilation errors, syntax errors, lint tips
- Provide language sandbox Go Playground, you can quickly learn the language itself
- Quick info on Hover can quickly provide documentation support
Advanced features
The plug-in also supports some advanced features.
The first is support for Go module mode and GOPATH mode, see the documentation for more details
Second, Go Language Server GOPLS is supported. For details, please refer to the documents on both sides and learn later
Pay attention to the point
There are some parts of the go language that are not very comfortable. For example, I encountered a point before, which is not supported by set by default. Today I encountered another point, go has an implicit semicolon after; In general, do not write the last semicolon. Simple statements are ok, but in the case of array, parameter, etc., there will be strange error, need to adapt to.
Reference
- Go – Visual Studio Marketplace
- Vscode-go/Go-with-VS-code-FAQ-and -Troubleshooting. Md at Master · Microsoft/VScode-Go
- GoLand: A Clever IDE to Go by JetBrains
- Vscode-go /gopls.md at Master · golang/vscode-go
- Vscode-go/changelog. md at Master · golang/vscode-go
- Md at master · golang/vscode-go
- Modules golang/go Wiki
- Blog.golang.org/using-go-mo…
- Golang.org/cmd/go/#hdr…