美文网首页
vs code配置golang环境

vs code配置golang环境

作者: hexg1016 | 来源:发表于2018-12-29 10:00 被阅读0次

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

    相关文章

      网友评论

          本文标题:vs code配置golang环境

          本文链接:https://www.haomeiwen.com/subject/iyhulqtx.html