A quick fix to the problem of VSCode failing to install GO plug ins in MacOS
- 2020-10-23 21:01:42
- OfStack
Problem reproduction
[
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing golang.org/x/lint/golint FAILED
Installing github.com/stamblerre/gocode FAILED
4 tools failed to install.
]VS COde opens the.go file to automatically install the plug-in, but 1 tool download failed.
Replacing the global agent is also not available.
I found a lot of tutorials, but maybe the directory has changed due to some version 1 issues, which caused Uka to stay here for a long time. Especially github. com/stamblerre/gocode.
To solve
The following actions are based on
$GOPATH
In this path, go in MacOS
$GOPATH
Can be typed at the terminal
go env
View the & # 8203;
$GOPATH
Position.
I the
$GOPATH
Position in
/Users/Apple/go
, be careful to switch to your own
$GOPATH
In the.
1. Create a directory
golang.org\x
, and enter the clone tools repository in the directory.
$ cd /Users/Apple/go/src
$ mkdir -p golang.org/x && cd golang.org/x
$ git clone https://github.com/golang/tools.git tools
$ git clone https://github.com/golang/lint.git
$ ls
lint tools
2, back to the
$GOPATH
Directory to install plug-ins
$ cd /Users/Apple/go
$ sudo go install golang.org/x/tools/cmd/guru
$ sudo go install golang.org/x/tools/cmd/gorename
$ sudo go install golang.org/x/lint/golint
Create a directory
github.com
, and go to the clone tool repository in the directory.
$ cd /Users/Apple/go/src
$ sudo mkdir -p github.com/stamblerre $$ cd github.com/stamblerre
$ sudo git clone https://github.com/stamblerre/gocode.git
$ ls
gocode
4. Go back to the $GOPATH directory and install the plug-in
$ cd /Users/Apple/go
$ sudo go install github.com/stamblerre/gocode
After all 4 plug-ins are installed, open an arbitrary.go file with VS Code, and the installation will not fail.
conclusion