首先,需要安装好 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",
],
首选项-设置 去掉 Use Language Server
脚本宝典总结
以上是脚本宝典为你收集整理的Vscode解决Golang无法跳转定义问题全部内容,希望文章能够帮你解决Vscode解决Golang无法跳转定义问题所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。