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
        }
    ]
}
    原文作者:杰克曼
    原文地址: https://segmentfault.com/a/1190000017991794
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞