vscode 配置 go 开发环境
2019-04-03 08:14
1366 查看
VScode and go
2019 vscode 配置 go 开发环境
起因
由于墙的原因,更新 vscode go 开发环境各种FAILED,网上看了很多材料没解决。
ctrl+shift+x,输入 go, 选第一个安装。
ctrl+shift+p,输入 go:install/update tools,安装。
Installing 15 tools at /home/sfw/go/bin gocode gopkgs go-outline go-symbols guru gorename dlv godef goreturns golint gotests gomodifytags impl fillstruct goplay Installing github.com/mdempsky/gocode FAILED Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED Installing github.com/ramya-rao-a/go-outline FAILED Installing github.com/acroca/go-symbols FAILED Installing golang.org/x/tools/cmd/guru FAILED Installing golang.org/x/tools/cmd/gorename FAILED Installing github.com/go-delve/delve/cmd/dlv SUCCEEDED Installing github.com/rogpeppe/godef SUCCEEDED Installing github.com/sqs/goreturns FAILED Installing golang.org/x/lint/golint FAILED Installing github.com/cweill/gotests/... FAILED Installing github.com/fatih/gomodifytags SUCCEEDED Installing github.com/josharian/impl FAILED Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED 9 tools failed to install.
解决方案
研究后发现,主要是 golang.org/x/tools, golang.org/x/lint 和 golang.org/x/net 这三个在 google 官网的包被墙。但是github上有,可以手动安装。
- 安装 go 扩展包。
- 配置 vscode。
安装 go 扩展包
linux下
cd $GOPATH git clone git@github.com:golang/tools.git ./src/golang.org/x/tools git clone git@github.com:golang/lint.git ./src/golang.org/x/lint git clone git@github.com:golang/net.git ./src/golang.org/x/net
经测试在 windows 版本还要再装 github.com/golang/lint 包
cd $env:GOPATH git clone git@github.com:golang/tools.git ./src/golang.org/x/tools git clone git@github.com:golang/lint.git ./src/golang.org/x/lint git clone git@github.com:golang/net.git ./src/golang.org/x/net git clone git@github.com:golang/lint.git ./src/github.com/golang/lint
在 shell 里安装
go install github.com/nsf/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/fatih/gomodifytags go install github.com/haya14busa/goplay/cmd/goplay go install github.com/josharian/impl go install github.com/davidrjenni/reftools/cmd/fillstruct go install github.com/rogpeppe/godef go install golang.org/x/tools/cmd/godoc go install github.com/sqs/goreturns go install github.com/golang/lint/golint
在 vscode 里确认一遍
Installing 15 tools at /home/sfw/go/bin gocode gopkgs go-outline go-symbols guru gorename dlv goreturns golint gogetdoc gotests gomodifytags impl fillstruct goplay Installing github.com/mdempsky/gocode SUCCEEDED Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED Installing github.com/ramya-rao-a/go-outline SUCCEEDED Installing github.com/acroca/go-symbols SUCCEEDED Installing golang.org/x/tools/cmd/guru SUCCEEDED Installing golang.org/x/tools/cmd/guru SUCCEEDED Installing golang.org/x/tools/cmd/gorename SUCCEEDED Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED Installing github.com/rogpeppe/godef SUCCEEDED Installing golang.org/x/tools/cmd/gorename SUCCEEDED Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED Installing github.com/sqs/goreturns SUCCEEDED Installing golang.org/x/lint/golint SUCCEEDED Installing github.com/sqs/goreturns SUCCEEDED
配置 vscode
打开方式
文件
->首选项
->设置
->{}
(在右上角,打开设置json)ctrl+,
->{}
(在右上角,打开设置json)ctrl+shift+p
->输入setting
设置的内容
//go "go.gopath": "", "go.inferGopath": true, "go.autocompleteUnimportedPackages": true, "go.gocodePackageLookupMode": "go", "go.gotoSymbol.includeImports": true, "go.useCodeSnippetsOnFunctionSuggest": true, "go.useCodeSnippetsOnFunctionSuggestWithoutType": true, "go.docsTool": "gogetdoc", "breadcrumbs.enabled": true,
如果win10下安装了wsl,可以设置shell为wsl。
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe", "terminal.external.windowsExec": "C:\\WINDOWS\\System32\\bash.exe",
参考
相关文章推荐
- vscode 配置golang go开发环境 IDE(2018年10月)
- 在VSCode中配置GO开发环境用户设置
- ubuntu /elementary os下vscode 配置go开发环境
- VSCode Python开发环境配置
- Mac上Go环境和VS Code的正确安装与配置方法
- VSCode Python开发环境配置的详细步骤
- VSCode 配置C/C++开发环境
- ubuntu 16.04 VSCode 配置C++开发环境
- windows环境下利用vscode搭建go语言的开发环境详解
- vs code 在windows10 64bit系统配置python开发环境
- 【学习笔记】在VSCode上配置typescript + nodejs 开发环境
- 在Visual Studio Code中配置GO开发环境的详细教程
- Go语言vscode环境配置
- Visual Studio Code中配置GO开发环境
- vscode 搭建go开发环境的13个插件的安装
- 在Visual Studio Code中配置GO开发环境
- Mac-配置VSCode的Java开发环境(Spring Boot)
- 为visual studio code配置go开发环境(windows)
- Node MCU ESP12E 1.0配置VScode开发环境