使用 VS CODE 调试 GO 项目

  1. 安装 go 插件,在扩展面板中搜索关键字 go,并下载安装
  2. 安装调试器:go get -u -v github.com/derekparker/delve/cmd/dlv
  3. 添加调试配置文件
{
   // 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": "Launch",
           "type": "go",
           "request": "launch",
           "mode": "debug",
           "remotePath": "",
           "port": 2345,
           "host": "127.0.0.1",
           "program": "${fileDirname}",
           "env": {
               "GOPATH":"C:/Users/Freeman/go"
           },
           "args": [],
           "showLog": true
       }
   ]
}

你可能感兴趣的:(使用 VS CODE 调试 GO 项目)