vscode是比较好用的,虽然goland自带插件但是收费,所以配置vscode虽然麻烦但是也值得。
Step1.下载安装vscode和golang
Download Visual Studio Code - Mac, Linux, Windowscode.visualstudio.comThe Go Programming Languagegolang.google.cnnext step 安装即可
Step2.vscode配置golang插件
Step3.环境变量path配置与gopath
这里我把gopath路径放在E盘;
右下角提示安装go开发插件,选择All install即可安装成功;
如果有墙原因使用git下载;
这里是非常痛苦和麻烦的;
在gopath下src创建http://golang.org/x
//目录创建成功后,在x目录中执行git clone https://github.com/golang/tools.git
//然后将下载的tools目录拷贝一份至golang目录,至此,目录结构变为:github.com-》golang—》toolsgolang.org->>x-->>tools//到此,当vscode再次出现安装提示的时候,我们点击安装,就可以安装成功了。//但是如果仍然不能安装成功,我们也可以手动安装,分别执行如下命令即可。go install github.com/ramya-rao-a/go-outlinego install github.com/acroca/go-symbolsgo install golang.org/x/tools/cmd/gurugo install golang.org/x/tools/cmd/gorenamego install github.com/josharian/implgo install github.com/rogpeppe/godefgo install github.com/sqs/goreturnsgo install github.com/golang/lint/golintgo install github.com/cweill/gotests/gotests
End.配置下vscode的settings.json即可愉快使用
ctrl+shift+p 输入:Preferences: Configure language specific settings
选择go语言
配置如下:
{"go.autocompleteUnimportedPackages": true,"go.gocodePackageLookupMode": "go","go.gotoSymbol.includeImports": true,"go.useCodeSnippetsOnFunctionSuggest": true,"go.inferGopath": true,"go.gopath": "C:/Users/Administrator/go","go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
}