首先,需要安装好 go 插件,插件市场搜索go,选一个即可安装。
然后,需要安装 go 的工具包。在 vscode 中,输入快捷键:command(ctrl) + shift + p,在弹出的窗口中,输入:go:install/Update Tools,回车后,选择所有插件(勾一下全选),点击确认,进行安装(设置GOPROXY)。
接下来,在项目的 settings.json 文件中添加配置:
"go.goroot": "D:\\Go",
"go.gopath": "D:\\gopath",
//第三方库代码提示
"go.inferGopath": true,
"go.formatTool": "goreturns",
//自动完成未导入的包
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.docsTool": "gogetdoc",
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.useLanguageServer": true,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},// Optional: Disable snippets, as they conflict with completion ranking."editor.snippetSuggestions": "none",
},"[go.mod]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
},"go.trace.server": "verbose",
"gopls": {
// Add parameter placeholders when completing a function.
"usePlaceholders": false,
// If true, enable additional analyses with staticcheck.
// Warning: This will significantly increase memory usage."staticcheck": false,
},"go.languageServerFlags": [
"-remote=auto", "-logfile=auto", "-debug=:0", "-rpc.trace",
],
【Vscode 解决Golang无法跳转到定义】首选项-设置 去掉 Use Language Server
文章图片
本文由博客一文多发平台 OpenWrite 发布!
推荐阅读
- Python进阶|警惕 Python 中少为人知的 10 个安全陷阱
- k8s|k8s(六)(配置管理与集群安全机制)
- Java程序|软件测试八款优秀的API安全测试工具,会用三款工作效率能提升50%
- 内网渗透|内网渗透-最实用的信息收集
- 定位|浅谈大规模红蓝对抗攻与防
- 计算机网络重点回顾