vs code配置golang环境

launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": []
}
]
}
settings.json
{

"files.autoSave": "onFocusChange",

"go.buildOnSave": true,

"go.lintOnSave": true,

"go.vetOnSave": true,

"go.buildFlags": [],

"go.lintFlags": [],

"go.vetFlags": [],

"go.useCodeSnippetsOnFunctionSuggest": false,

"go.formatOnSave": false,

"go.formatTool": "goreturns",

"go.docsTool": "gogetdoc",

"go.gopath": "${env:GOPATH};${workspaceRoot}",

"editor.fontSize": 18

}
tasks.json
{
// See Tasks in visual Studio Code
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "go",//命令 xxx.exe
"isShellCommand": true,
//"args": ["build","-v","{file}"],//固定参数,多的用逗号分割 "echoCommand":true,//是否显示命令 "showOutput": "always", "suppressTaskName": true,// "options": { "cwd": "{fileDirname}"
},
"windows": {
"options": {
"env": {
"GOPATH": "{env:GOPATH};{workspaceRoot}"
}
}
},
"tasks": [
{
"taskName": "build",
"args": ["build","-i"]
},
]
}
vscode开发golang时会出现,dot import的时候无法跳转到定义的问题。
解决方式:
go get github.com/zmb3/gogetdoc
然后在vs code的settings.json配置文件中添加
"go.docsTool": "gogetdoc",

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容