VS Code中golang环境配置
程序员文章站
2024-01-10 09:38:04
...
1.VSCode 建议安装以下插件:
首先你必须安装 Golang 插件,然后再给 Go 安装工具包。
在 VS Code 中,使用快捷键:command+shift+P
,然后键入:go:install/update tools
,将所有 16 个插件都勾选上,然后点击 OK 即开始安装。
Installing 16 tools at /Users/maiyang/develop/goworkspace//bin
gocode
gopkgs
go-outline
go-symbols
guru
gorename
dlv
godef
godoc
goreturns
golint
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/gorename SUCCEEDED
Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing golang.org/x/tools/cmd/godoc SUCCEEDED
Installing github.com/sqs/goreturns SUCCEEDED
Installing github.com/golang/lint/golint SUCCEEDED
Installing github.com/cweill/gotests/... SUCCEEDED
Installing github.com/fatih/gomodifytags SUCCEEDED
Installing github.com/josharian/impl SUCCEEDED
Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED
All tools successfully installed. You're ready to Go :).
2.代码自动补全
File->Preferences -> Setting ,然后输入 go,然后选择 setting.json
,填入你想要修改的配置。或者通过右上角图标,进入设置 setting.json
页面,添加如下字段信息。实现代码自动补全需要设置字段为go.useCodeSnippetsOnFunctionSuggest ,go.inferGopath。
"go.autocompleteUnimportedPackages": true, //自动完成未导入的包
“go.useCodeSnippetsOnFunctionSuggest”: true, //自动提示代码,代码自动补全
"go.docsTool": "gogetdoc", //支持跳转到文件名含.路径等功能
"go.inferGopath": true, //开启推断gopath的功能
"go.gocodePackageLookupMode": "go", //代码包查询模式
"go.gotoSymbol.includeImports": true
可参考setting.json文件格式。
{
"go.goroot": "",
"go.gopath": "",
"go.inferGopath": true,
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.docsTool": "gogetdoc",
}
推荐阅读
-
VS Code中golang环境配置
-
vs code配置golang环境
-
Vs Code Golang代码没有自动补全修复
-
水火也相容!巧妙在IIS中配置PHP调试环境
-
Apache2.4+php5.5+mysql5.5环境配置问题,phpinfo中不显示mysql扩展项
-
在Win2003(64位)中配置IIS6+PHP5.2.17+MySQL5.5的运行环境,php5.2.17mysql5.5
-
Mac下配置Golang环境
-
vs code 配置c/c++环境的详细教程(推荐)
-
8.翻译系列: EF 6中配置领域类(EF 6 Code-First 系列)
-
在CentOS6.4中安装配置LAMP环境的详细步骤_PHP教程