vs code配置golang环境

2018-12-29  本文已影响0人  hexg1016

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",

上一篇下一篇

猜你喜欢

热点阅读