Tag Archives: Go Installation failure

Go: How to Fix plug-in installation failure in vscode of windows system

1.Run go env -w GO111MODULE=on //enable mod   
  Run go env -w GOPROXY=https://goproxy.cn,direct //set proxy
2. Go to GOPATH directory, create src/golang.org/x/ directory, go to src/golang.org/x/ directory
    git clone https://github.com/golang/tools.git
    git clone https://github.com/golang/lint.git
3.Then you can install the go plugin in vscode as prompted (odds are it still won't work)
 So you need to execute the following command in the terminal of %GOPATH%/src directory
    go get -u -v github.com/mdempsky/gocode
    go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
    go get -u -v github.com/ramya-rao-a/go-outline
    go get -u -v github.com/acroca/go-symbols
    go get -u -v golang.org/x/tools/cmd/guru
    go get -u -v golang.org/x/tools/cmd/gorename
    go get -u -v github.com/go-delve/delve/cmd/dlv
    go get -u -v github.com/stamblerre/gocode
    go get -u -v github.com/rogpeppe/godef
    go get -u -v github.com/sqs/goreturns
    go get -u -v golang.org/x/lint/golint
    go get -u -v github.com/cweill/gotests/...
    go get -u -v github.com/fatih/gomodifytags
    go get -u -v github.com/josharian/impl
    go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
    go get -u -v github.com/haya14busa/goplay/cmd/goplay
    go get -u -v github.com/godoctor/godoctor
4.There may still be errors after performing the above steps, just follow the instructions prompted by vscode to fix them.


Note: There may be problems with the following:
    Error: go: cannot find main module; see 'go help modules'
    Solution go env -w GO111MODULE=off
GO111MODULE There are three values: off, on and auto (default).

GO111MODULE=off, no module support, find dependencies from $GOPATH and vendor folders.
GO111MODULE=on, with module support, go ignores the $GOPATH and vendor folders and only downloads dependencies based on go.mod.
GO111MODULE=auto, the go command line will decide whether to enable the modules feature based on the current directory.
There are two scenarios.
	module support is enabled when the project is outside of $GOPATH/src and the project root directory has a go.mod file.
	the project is inside $GOPATH/src and module support is not provided even if the go.mod file exists.