Vscode installation go third-party expansion pack pit logging detailed tutorial


1. Installation of go extension package in vscode will not be described.

2. After installing the go extension package, create the gopath environment variable

3. Path will be automatically added, if not, it can be manually added

4. Create your own workspace in gopath directory (it’s not clear why it must be created in gopath). Mine is workspace (the name can be customized)

5. Open vscode, file – open folder, select gopath directory

6. Create the HelloWorld directory in workspace (I call it project space)

7. Configure the setting.json file

Add the following configuration:

8. Write HelloWorld code as follows, can be directly copied

package main
import "fmt"
func main() {

 fmt.Println("Hello world!")


Save, restart vscode

9. After restarting vscode, the third-party class library of go will be loaded automatically. Pay attention to the output. Because of the limitation of FQ, you can’t download it from the golang.org Download the corresponding class package. Everyone’s situation is different. Basically, my installation fails, as follows:

Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs FAILED
Installing github.com/ramya-rao-a/go-outline FAILED               
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/go-delve/delve/cmd/dlv SUCCEEDED
Installing github.com/stamblerre/gocode FAILED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing github.com/sqs/goreturns FAILED
Installing golang.org/x/lint/golint FAILED

10. Vscode auto install failed, manual install

The first step is in% gopath% \ Src\ golang.org \Open git bash (if there is no corresponding golang.org Directory, which can be created manually), execute git clone http://github.com/golang/tools 。 (when installing a third-party class package manually, you must first install the tools class package) you must use git to clone, otherwise install other components such as go get – U – V github.com/cweill/gotests 。 Package will appear golang.org/x/tools/imports :directory”D:\\GoPath\\src\\ golang.org \\X \ \ tools \ \ imports “is not using a known version control system error.
Step 2: after downloading tools, enter% gopath% \ Src\ golang.org \Click Shift + right-click to open the command window, execute go install, and guru performs the same operation.
Step 3 execute go get – U – V in the command line window github.com/newhook/go -Symbols, install go symbols. Do the same for the others. See the package chain below.

First in% gopath% / SRC/ github.com As follows:

git clone https://github.com/mdempsky/gocode
git clone https://github.com/uudashr/gopkgs/cmd/gopkgs
git clone https://github.com/ramya-rao-a/go-outline
git clone https://github.com/acroca/go-symbols
git clone https://golang.org/x/tools/cmd/guru
git clone https://golang.org/x/tools/cmd/gorename
git clone https://github.com/go-delve/delve/cmd/dlv
git clone https://github.com/stamblerre/gocode
git clone https://github.com/rogpeppe/godef
git clone https://github.com/sqs/goreturns
git clone https://golang.org/x/lint/golint

Then execute under% gopath%

go install github.com/mdempsky/gocode
go install github.com/uudashr/gopkgs/cmd/gopkgs
go install github.com/ramya-rao-a/go-outline
go install github.com/acroca/go-symbols
go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install github.com/go-delve/delve/cmd/dlv
go install github.com/stamblerre/gocode
go install github.com/rogpeppe/godef
go install github.com/sqs/goreturns
go install golang.org/x/lint/golint


From the github.com When downloading, sometimes you will find problems with the directory, such as downloading github.com/mdempsky/gocode , after the download is complete, it will be in% gopath% / SRC/ github.com Create the gocode directory (or generate mdempsky (empty) and gocode directory) under the directory. In this case, you need to manually move the gocode to the mdempsky directory.

If package appears golang.org/x/tools/go/buildutil : cannot download, http://github.com/golang/tools Use execute protocol error. It is not difficult to see that it is caused by downloading tools. Because we have installed tools above, and at this time, go symbols have passed go Get down. At this time, we directly enter% gopath% \ Src\ github.com \In the newhook / go symbols directory, enter the command line and execute go install. The installation is successful- symbols.exe Already appears in the% gopath% \ bin directory.

11. If you open vscode (the default go project project project), the

It can be installed according to the above method.

12. The plug-in that needs to be installed after installing vscode. The following name is the EXE file generated under% gopath% / bin

github.com/mdempsky/gocode          gocode
github.com/uudashr/gopkgs/cmd/gopkgs    gopkgs
github.com/ramya-rao-a/go-outline      go-outline
github.com/acroca/go-symbols          go-symbols
golang.org/x/tools/cmd/guru          guru
golang.org/x/tools/cmd/gorename      gorename
github.com/derekparker/delve/cmd/dlv       dlv
github.com/stamblerre/gocode          gocode-gomod
github.com/rogpeppe/godef        godef
github.com/ianthehat/godef          godef-gomod
github.com/sqs/goreturns          goreturns
golang.org/x/lint/golint          golint

You can also generate a batch file

mkdir  %GOPATH%\\src\\golang.org\\x
git clone https://github.com/golang/tools.git %GOPATH%\\src\\golang.org\\x\\tools

go get -v github.com/mdempsky/gocode
go get -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -v github.com/ramya-rao-a/go-outline
go get -v github.com/acroca/go-symbols
go get -v golang.org/x/tools/cmd/guru
go get -v golang.org/x/tools/cmd/gorename
go get -v github.com/derekparker/delve/cmd/dlv
go get -v github.com/stamblerre/gocode
go get -v github.com/rogpeppe/godef
go get -v github.com/ianthehat/godef
go get -v github.com/sqs/goreturns
go get -v github.com/golang/lint%
git clone https://github.com/golang/lint.git %GOPATH%\\src\\golang.org\\x\\lint

go build -o %GOPATH%\\bin\\gocode.exe github.com/mdempsky/gocode
go build -o %GOPATH%\\bin\\gopkgs.exe github.com/uudashr/gopkgs/cmd/gopkgs
go build -o %GOPATH%\\bin\\go-outline.exe github.com/ramya-rao-a/go-outline
go build -o %GOPATH%\\bin\\go-symbols.exe github.com/acroca/go-symbols
go build -o %GOPATH%\\bin\\guru.exe golang.org/x/tools/cmd/guru
go build -o %GOPATH%\\bin\\gorename.exe golang.org/x/tools/cmd/gorename
go build -o %GOPATH%\\bin\\dlv.exe github.com/derekparker/delve/cmd/dlv
go build -o %GOPATH%\\bin\\gocode-gomod.exe github.com/stamblerre/gocode
go build -o %GOPATH%\\bin\\godef.exe github.com/rogpeppe/godef
go build -o %GOPATH%\\bin\\godef-gomod.exe github.com/ianthehat/godef
go build -o %GOPATH%\\bin\\goreturns.exe github.com/sqs/goreturns
go build -o %GOPATH%\\bin\\golint.exe golang.org/x/lint/golint


matters needing attention:

1) Two gocodes will be found, github.com/mdempsky/gocode And github.com/stamblerre/gocode When you use go install, only the name is generated gocode.exe File, so the command and parameters of go build – O are used here.

2) . after installation github.com/golang/tools After that, golang.org/x/tools/cmd/guru And golang.org/x/tools/cmd/gorename You can directly enter the corresponding directory and execute [go install] to install.

Attachment: effect of all third party packages installed:


This article on the vscode installation go third-party expansion pack filling in the record of the article introduced here, more related vscode go expansion pack content please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!

Recommended Today

Elasticsearch database | elasticsearch-7.5.0 application foundation actual combat

Elasticsearch is a distributed and restful search and data analysis engine. ——Elastic stack website On elasticsearch’s “love and hate”“ Perhaps when it comes to search servers, most people will think of Solr, elasticsearch, and even the self-development of large domestic manufacturers. With the advent of the era of artificial intelligence and big data, a series […]