1. 程式人生 > 實用技巧 >vscode 配置go開發環境

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":"\n",//formattingonlysupportsLFlineendings
    "emmet.excludeLanguages":[
    
    "markdown"
    ],
    "go.addTags":{
    
    }
    }