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","{fileDirname}"
},
"windows": {
"options": {
"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",

你可能感兴趣的:(vs code配置golang环境)