1、 可以先设置个代理:
1、1 set GO111MODULE=on
1、2 set goproxy=https://goproxy.io
2、 添加Golang的插件工作目录:%GOPATH/src/golang.org/x/
3、 切换至%GOPATH/src/golang.org/x/后使用git拉取依赖代码git clone https://github.com/golang/tools.git tools
4、 执行以下命令
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/derekparker/delve/cmd/dlv
go install github.com/stamblerre/gocode
go install github.com/rogpeppe/godef
go install github.com/ianthehat/godef
go install github.com/sqs/goreturns
go install golang.org/x/lint/golint
go install github.com/cweill/gotests/...
go install github.com/fatih/gomodifytags
go install github.com/josharian/impl
go install github.com/davidrjenni/reftools/cmd/fillstruct
go install github.com/haya14busa/goplay/cmd/goplay
5、 肯定会看到如下的报错
C:Usersabel1go> go install golang.org/x/lint/golint
can't load package: package golang.org/x/lint/golint: cannot find package "golang.org/x/lint/golint" in any of:
C:Gosrcgolang.orgxlintgolint (from $GOROOT)
C:Usersabel1gosrcgolang.orgxlintgolint (from $GOPATH)
解决办法:
这是因为 golint 的源码在lint下,而不是tools,需要单独拉取 golint 源码。
5、1 进入%GOPATH%srcgolang.orgx,执行下列命令拉取 golint 源码:git clone https://github.com/golang/lint
5、2 最后回到%GOPATH%,通过go install安装 golint:go install github.com/golang/x/lint/golint
6、 重启vscode
安装的组件 | 默认安装状态 | 组件备注 | github.com->golang.org |
---|---|---|---|
go get -u -v github.com/nsf/gocode | SUCCEEDED | 自动补全 | |
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs | SUCCEEDED | 自动补全未导入的包 | |
go get -u -v github.com/ramya-rao-a/go-outline | SUCCEEDED | 当前文件中按符号搜索 | https://github.com/golang/tools |
go get -u -v github.com/acroca/go-symbols | SUCCEEDED | 当前workspace中按符号搜索 | |
go get -u -v golang.org/x/tools/cmd/guru | SUCCEEDED | 查找所有引用组件 | |
go get -u -v golang.org/x/tools/cmd/gorename | SUCCEEDED | 重命名符号 | |
go get -u -v github.com/fatih/gomodifytags | SUCCEEDED | 修改结构上的标签 | |
go get -u -v github.com/haya14busa/goplay/cmd/goplay | SUCCEEDED | for running current file in the Go playground | |
go get -u -v github.com/josharian/impl | SUCCEEDED | for generating stubs for interfaces | |
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct | SUCCEEDED | for filling a struct literal with default values | |
go get -u -v github.com/rogpeppe/godef | SUCCEEDED | 转到定义2 | |
go get -u -v golang.org/x/tools/cmd/godoc | SUCCEEDED | 鼠标悬停显示文档注释2 | |
go get -u -v sourcegraph.com/sqs/goreturns | SUCCEEDED | 格式化代码2 | |
go get -u -v github.com/golang/lint/golint | SUCCEEDED | for linting | https://github.com/golang/lint |
go get -u -v github.com/cweill/gotests/... | SUCCEEDED | 生成单元测试 | |
go get -u -v github.com/derekparker/delve/cmd/dlv | SUCCEEDED | 调试 | |
go get -u -v github.com/zmb3/gogetdoc | 转到定义2/鼠标悬停显示注释2 | ||
go get -u -v golang.org/x/tools/cmd/goimports | 格式化代码2 |