vscode 配置go开发环境

vscode 配置go开发环境

安装vscode插件

Visual Studio Code的配置选项支持Go插件的设置,可以通过用户偏好设置或workspace设置进行配置。在菜单File->Preferences处可以找到。

安装go模块

vscode 死活下不下来,只能自己去下载了

go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols

调试工具dlv debug下载

https://github.com/go-delve/delve

进入到gopath中,自己进行安装go install

setting.json

打开工作区的json文件,将下列内容复制进去

{
        "http.proxy": "http://127.0.0.1:7890",
        "go.useLanguageServer": true,
        "go.autocompleteUnimportedPackages": true,   
        "timeline.excludeSources": [],
        "go.inferGopath": true,
        "go.gotoSymbol.includeImports": true,
        "go.useCodeSnippetsOnFunctionSuggest": true,
        "go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
        "go.docsTool": "gogetdoc",
    
        "[go]": {
            "editor.snippetSuggestions": "none",
            "editor.formatOnSave": true,
            "editor.codeActionsOnSave": {
                "source.organizeImports": true
            }
        },
        
        
        "files.eol": "
", // formatting only supports LF line endings
        "emmet.excludeLanguages": [
        
            "markdown"
        ],
        "go.addTags": {
        
        }
    }
原文地址:https://www.cnblogs.com/tomyyyyy/p/14105724.html