1. Installation of the environment
Go SDK Download and install for: https://golang.org/dl/
Visual Studio Code downloads and installs as: Https://code.visualstudio.com/Download
Everyone according to different operating system selection, installation is relatively simple, basically the next step is completed
After the installation is complete, you can view the version of Go command: Go version
View the GO Environment configuration information command: Go env
2. Tool configuration 2.1go plug-in installation
输入关键字“go”,回车查询,选择第一个,点击安装即可。
2.2VS Code Configuration
Open Visual Studio Code and find the menu code->preferences->settings
{ "go.autocompleteUnimportedPackages": true, "files.autoSave": "onFocusChange", "go.buildOnSave": "package", "go.lintOnSave": "package", "go.vetOnSave": "package", "go.buildFlags": [], "go.lintFlags": [], "go.vetFlags": [], "go.useCodeSnippetsOnFunctionSuggest": false, "go.formatTool": "goreturns", "go.gopath": "/Users/[username]/go", "go.goroot": "/usr/local/go",}
2.3 Plugin Folder Configuration
Create a new Folder "Golang.org" in the Gopath corresponding directory, in the Golang.org folder in the new folder "X",
Open the command-line tool and run the following command:
- Switch current directory to X:CD $GOPATH/src/golang.org/x/
- Download tools tools: Git clone https://github.com/golang/tools.git Tools
2.4 Installing Plugins
Create a new Demo project folder under GOPATH->SRC, such as Demo1, create a new file Demo.go under Demo1, and open the folder with VS code, such as:
Vscode will automatically prompt to install the plug-in package, the bottom right corner of the figure, click "Install all" to install all plugins
If a package that cannot be downloaded can be downloaded using git clone, the download is completed and copied to the corresponding directory:
如:git clone https://github.com/cweill/gotests
2.5 Installing Xcode-select
Run the following command:
xcode-select --install
2.6 Installing Delve
Switch to the path first:
cd /Users/[username]/go/bin
Run the following command to install the plugin delve
go get -u github.com/derekparker/delve/cmd/dlv
2.7 Plugin Introduction
- Colorization code with color?
- Completion Lists Code Auto-complete (using Gocode)
- Snippets Code Snippets?
- Quick Info Prompt information (using godef)?
- Goto definition jumps to definitions (using Godef)?
- Find References Search reference (using go-find-references)?
- File Outline Document Outline (using Go-outline)?
- Workspace symbol Search Workspace sign searching (using Go-symbols)?
- Rename renaming (using Gorename)?
- Build-on-save Save build (using Go build or go test)?
- Format formatted (using Goreturns or Goimports or gofmt)?
- ADD Imports Auto-complete import of packages not imported (using gopkgs)?
- Linter Static analysis Check (using Golint or Gometalinter)?
- Debugging debug code (using delve)?
- errorchecking check for unchecked errors in your code (using Errcheck)?
- Varchecking find global variables and constants that are not called (using Varcheck)?
- Unusedcode find code that is not called (using Deadcode)
Go locale installation-mac