Go——vscode調試go語言 代碼提示 代碼跳轉


Mac機下執行命令

更改代理,安裝庫

go env
export GOPROXY=https://goproxy.io,direct go get -v github.com/go-delve/delve/cmd/dlv go get -v github.com/ramya-rao-a/go-outline go get -v github.com/uudashr/gopkgs/v2/cmd/gopkgs

也可將GOPROXY放在環境變量中,讓其全局生效

重啟vscode

shift+cammond+p,輸入go,找到go:install/Update Tools,全選,點ok。

Installing github.com/mdempsky/gocode (/Users/chong/go/bin/gocode) SUCCEEDED
Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs (/Users/chong/go/bin/gopkgs) SUCCEEDED
Installing github.com/ramya-rao-a/go-outline (/Users/chong/go/bin/go-outline) SUCCEEDED
Installing github.com/acroca/go-symbols (/Users/chong/go/bin/go-symbols) SUCCEEDED
Installing golang.org/x/tools/cmd/guru (/Users/chong/go/bin/guru) SUCCEEDED
Installing golang.org/x/tools/cmd/gorename (/Users/chong/go/bin/gorename) SUCCEEDED
Installing github.com/cweill/gotests/... (/Users/chong/go/bin/gotests) SUCCEEDED
Installing github.com/fatih/gomodifytags (/Users/chong/go/bin/gomodifytags) SUCCEEDED
Installing github.com/josharian/impl (/Users/chong/go/bin/impl) SUCCEEDED
Installing github.com/davidrjenni/reftools/cmd/fillstruct (/Users/chong/go/bin/fillstruct) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay (/Users/chong/go/bin/goplay) SUCCEEDED
Installing github.com/godoctor/godoctor (/Users/chong/go/bin/godoctor) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv (/Users/chong/go/bin/dlv) SUCCEEDED
Installing github.com/stamblerre/gocode (/Users/chong/go/bin/gocode-gomod) SUCCEEDED
Installing github.com/rogpeppe/godef (/Users/chong/go/bin/godef) SUCCEEDED
Installing github.com/sqs/goreturns (/Users/chong/go/bin/goreturns) SUCCEEDED
Installing golang.org/x/lint/golint (/Users/chong/go/bin/golint) SUCCEEDED

All tools successfully installed. You are ready to Go :).

 首選項-設置 去掉 Use Language Server

 

 

 

 

 

vscode的launch.json文件

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "test_go",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}/src/test.go"
        },
        {
            "name": "gateway",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "cwd":"${workspaceFolder}/src",
            "program": "${workspaceFolder}/src/main.go",
            "env": {},
            "args": []
        }
    ]
}

 

調試效果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM