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": []
        }
    ]
}

 

调试效果

 

posted @ 2022-02-17 12:23  会飞的斧头  阅读(3137)  评论(0编辑  收藏  举报