在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
vscode安装go的很多插件都是失败,如下: Installing 5 tools at E:\www\go_project\bin go-symbols guru gorename goreturns golint Installing github.com/acroca/go-symbols FAILED Installing golang.org/x/tools/cmd/guru FAILED Installing github.com/sqs/goreturns FAILED 1 tools failed to install. goreturns: Error: Command failed: D:\softs\Go\bin\go.exe get -u -v github.com/sqs/goreturns github.com/sqs/goreturns (download) package golang.org/x/tools/imports: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\imports" is not using a known version control system github.com/sqs/goreturns (download) package golang.org/x/tools/imports: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\imports" is not using a known version control system Installing golang.org/x/tools/cmd/gorename FAILED Installing github.com/sqs/goreturns FAILED Installing golang.org/x/lint/golint FAILED 5 tools failed to install. go-symbols: Error: Command failed: D:\softs\Go\bin\go.exe get -u -v github.com/acroca/go-symbols github.com/acroca/go-symbols (download) package golang.org/x/tools/go/buildutil: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\go\\buildutil" is not using a known version control system github.com/acroca/go-symbols (download) package golang.org/x/tools/go/buildutil: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\go\\buildutil" is not using a known version control system guru: Error: Command failed: D:\softs\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/guru package golang.org/x/tools/cmd/guru: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\cmd\\guru" is not using a known version control system package golang.org/x/tools/cmd/guru: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\cmd\\guru" is not using a known version control system gorename: Error: Command failed: D:\softs\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/gorename package golang.org/x/tools/cmd/gorename: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\cmd\\gorename" is not using a known version control system package golang.org/x/tools/cmd/gorename: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\cmd\\gorename" is not using a known version control system goreturns: Error: Command failed: D:\softs\Go\bin\go.exe get -u -v github.com/sqs/goreturns github.com/sqs/goreturns (download) package golang.org/x/tools/imports: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\imports" is not using a known version control system github.com/sqs/goreturns (download) package golang.org/x/tools/imports: directory "E:\\www\\go_project\\src\\golang.org\\x\\tools\\imports" is not using a known version control system golint: Error: Command failed: D:\softs\Go\bin\go.exe get -u -v golang.org/x/lint/golint Fetching https://golang.org/x/lint/golint?go-get=1 https fetch failed: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. package golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) Fetching https://golang.org/x/lint/golint?go-get=1 https fetch failed: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. package golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
最后在网上找到了解决办法。概要如下: 1.Tips:安装之前先检查下 %GoPath%\src\golang.org\x 下的tools/lint是否是从github获取的最新版本(注意一定要是git clone),正确如下图所示 因为后面安装 组件会大量用到这个tools和lint,如果不是最新或不是git clone更新组件会出现大量的: 1)在%GoPath%\src\golang.org\x 目录下git clone [email protected]:golang/tools.git,注意,只能git clone 2)在%GoPath%\src\golang.org\x 目录下git clone [email protected]:golang/lint.git,注意,只能git clone 2.官方文档说明 https://github.com/Microsoft/vscode-go/wiki/Go-tools-that-the-Go-extension-depends-on
Go: Install/Update Tools
组件安装过程稍微有一点慢,耐心的等待...
经过步骤三的tools和lint的clone后安装正常都应该是SUCCEEDED ,且不需要墙,如遇个别安装FAILED 再单独执行go get ...,看还缺少什么在github.com/golang 中找到相应的组件按同样的方法clone在golang.org/x文件夹下
3.cannot find package错误 检查go环境配置,新安装的go1.10.2的版本默认会在当前用户新增一个GOPATH导致冲突无法编译,删除即可
4.调试 1)vscode打开main.go直接F5就可以运行&调试 2)生成exe,vscode F5运行会在根路径下生成一个debug文件,把debug文件重命名加.exe后缀可以直接当应用程序运行 go build -o demo.exe main.go 意思是main.go生成名为demo.exe应用程序,go build生成的exe实际比debug要小。 原文地址:https://www.cnblogs.com/nickchou/p/9038114.html |
请发表评论