In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces vscode how to configure the go language development environment, the article is very detailed, has a certain reference value, interested friends must read it!
Golang environment configuration
1) first download the installation package suitable for your system
2) download and install to the specified directory. I am here (D:\ Go).
3) configure Glang environment variables
Go to my computer-> Advanced Settings-> Environment variable to see if the GOROOT variable exists and whether GOROOT is also set in the Path variable. If not, add a GOROOT variable and enter the root directory of the Go you just installed, such as mine: d:\ Go\.
Then edit the Path variable and add ";% GOROOT%\ bin" at the end.
Tip: the image above shows the previously configured environment, GOPATH= "D:\ GO\ MyGO", which can be modified according to your own environment.
The go command relies on an environment variable: GOPATH, which is not the directory where Go is installed, but your work (project) directory (where all your code will be located). There can be multiple GOPATH. The windows is distinguished by a semicolon (;). The Linux system is a colon (:). When there is more than one GOPATH, the default will put the contents of the go get in the first directory.
Here we create a new GOPATH variable, take mine as an example: d:\ Go\ MyGolang, and create the relevant directory as follows:
Then edit the Path variable and add ";% GOPATH%\ bin" at the end.
4) restart the operating system and verify through the command
Install and configure VSCode
Just choose the corresponding version of your system.
Install the golang plug-in
Enter Visual Studio Code, use the shortcut F1, and open the command panel
Enter exten at the cursor above, and then select "Extensions:Install Extension", as shown in the following figure
Query and install the Go plug-in
Tip: in the plug-in list, select Go to install. After installation, you will be prompted to restart Visual Studio Code. Since I have already installed it here, the "Install" option will not appear.
Turn on the auto-save function
Open Visual Studio Code and find the menu File-> Preferences-> Settings, as shown below:
Select "User Settings" to configure the following
{"files.autoSave": "onFocusChange", "editor.fontSize": 18, "go.goroot": "D:\\ Go", "go.gopath": "D:\\ Golang\\ MyGO"}
Others just keep the default configuration.
Execute relevant commands (install git by yourself)
1) install gocode
Open a command prompt (as an administrator) and enter:
Go get-u-v github.com/nsf/gocode
2) install godef
Go get-u-v github.com/rogpeppe/godef
3) install golint
# create $GOPATH/src/golang.org/xcd $GOPATH/src/golang.org/xgit clone https://github.com/golang/tools.gitgit clone https://github.com/golang/lint.git#, execute go get golang.org/x/lint/golint after completing the above steps
If you encounter an error like the following, you can download the package locally by git clone, and then install it to solve the problem.
4) install go-find-references
Go get-u-v github.com/lukehoban/go-find-references
5) install go-outline
Go get-u-v github.com/lukehoban/go-outline
6) install goreturns
Go get-u-v sourcegraph.com/sqs/goreturns
7) install gorename
Go get-u-v golang.org/x/tools/cmd/gorename
Tip: if you are also prompted to report an error, because the previous git clone has come down, you can execute "go install golang.org/x/tools/cmd/gorename".
8) install gopkgs
Go get-u-v github.com/tpng/gopkgs
9) install go-symbols
Go get-u-v github.com/newhook/go-symbols
Write a program for testing
You can see that the relevant prompts can be made. Here we execute the complete program to test whether the program is normal.
These are all the contents of the article "how to configure the go language development environment for vscode". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.