VSC的golang的插件因为墙的原因,不方便直接安装,手动设置代理,然后执行go get进行安装。
首先,go env设置代理,开启GO111MODULE:
go env -w GOPROXY=https://goproxy.cn,direct
# Set environment variable allow bypassing the proxy for selected modules
go env -w GOPRIVATE=*.corp.example.com
go env -w GO111MODULE=on
接着,就可以进行插件的安装了,以下是 go插件提供的插件用到的命令:
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/zmb3/gogetdoc
go get -u -v golang.org/x/lint/golint
go get -u -v github.com/fatih/gomodifytags
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v github.com/cweill/gotests/...
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/josharian/impl
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -u -v golang.org/x/tools/gopls@latest
有些插件还是不用gomod的方式安装会好些会更好,不然不会出现悬停提示,自动对齐什么的。关闭后重新安装下。
go env -w GO111MODULE=off
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/stamblerre/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v golang.org/x/lint/golint
因为官方提示说,这些插件支持不好;https://github.com/microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code
参考链接:
https://blog.csdn.net/yxf771hotmail/article/details/88233857
https://www.cnblogs.com/rongfengliang/p/11419210.html
卸载VSC:
https://blog.csdn.net/qq_36279445/article/details/79650059
============================================================================================
今天手残升级了VSC,然后各种问题提示,手残之下,把目录都删了,最后不得不把整个vcs都彻底卸载,重新安装golang,vsc。从早上十点多搞到现在,终于又把开发环境恢复到清爽的样子。之前遗留太多,难怪vsc越来越卡。
因为插件问题,折腾很久,最后找到七牛云的代理地址,用上之后,插件都能安装了,(感谢)。
=============================================================================================
#关闭go mod模式,要项目不用go mod进行管理的话,就会build出错。
PS F:\go\src\go_dev\day6\homework\work02> go build .\main\...
go: cannot find main module; see 'go help modules'
PS F:\go\src\go_dev\day6\homework\work02>
#关闭
PS F:\go\src\go_dev\day6\homework\work02\main> go env -w GO111MODULE=off
#重新build,ok
PS F:\go\src\go_dev\day6\homework\work02> go build .\main\...
PS F:\go\src\go_dev\day6\homework\work02> .\main.exe