mac vscode 调试配置

安装Go语言调试工具dlv

前提

需要安装Xcode命令行工具。运行以下命令安装:

xcode-select --install

dlv安装

go install github.com/derekparker/delve/cmd/dlv

配置

配置settings.json中的GOROOT和GOPATH
点击VS Code,点击最顶部栏的Code选项,选中Preferences,点击Settings,选中Extensions,点击Go configuration,在点击Edit in settings.json,打开settings.json文件,可以通过搜索go.go查到,settings.json 文件里面默认的go.gopath和go.goroot都是null,需要自己设置,设置完gopath和goroot后按command+s保存文件。

配置launch.json

{ 
    "version": "0.2.0",
    "configurations": [
        {
            "name": "te",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 23456,
            "host": "127.0.0.1",
            "program": "/Users/reyun/go/src/test/build.go",
            "args": [],
            "showLog": true,
            "trace": true
        }
    ]
}

相关推荐