Go installation will not be explained here, please see: [go study notes. Chapter 2] 2. go language development tools and installation and configuration SDK , here is an explanation that when using vscode, an install message often pops up on the lower right foot go plugin, as follows:
At this time, click install to install, sometimes an error will be reported:
gocode-gomod: failed to install gocode-gomod(github.com/stamblerre/[email protected]): Error: Command failed: /opt/go/bin/go get -x -d github.com/stamblerre/[email protected]
...
Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/v2/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
...
Solution:
Execute the following two commands
# 旧版,已废弃
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
# 新版改成如下链接
go env -w GO111MODULE=on
go env -w GOPROXY=https://proxy.golang.com.cn,direct
Then close vscode and reopen it , click install again
Tools environment: GOPATH=/var/www/go/projects
Installing 3 tools at /var/www/go/projects/bin in module mode.
dlv
staticcheck
gopls
Installing github.com/go-delve/delve/cmd/dlv@latest (/var/www/go/projects/bin/dlv) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (/var/www/go/projects/bin/staticcheck) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (/var/www/go/projects/bin/gopls) SUCCEEDED
All tools successfully installed. You are ready to Go. :)
Successful installation