mac vscode 調試配置

安裝Go語言調試工具dlv

前提

須要安裝Xcode命令行工具。運行如下命令安裝:git

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保存文件。github

配置launch.jsonjson

{ 
    "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
        }
    ]
}
相關文章
相關標籤/搜索