在Linux里面使用gdb/delve工具来调试程序。
安装
Linux
1 | go get github.com/go-delve/delve/cmd/dlv |
vscode中的-workspace中配置一份调试选项:
1 | "configurations": [ |
使用vscode,安装连接到远程,工具栏里面选择“运行”-“安装附加调试器”
1 | Could not attach to pid 2956: this could be caused by a kernel security setting, try writing "0" to /proc/sys/kernel/yama/ptrace_scope |
远程调试
1 | go install github.com/go-delve/delve/cmd/dlv@latest |
{
“name”: “Attach to Remote”,
“type”: “go”,
“request”: “attach”,
“mode”: “remote”,
“remotePath”: “/home/youruser/your_project”, // 改成你远程项目路径
“port”: 2345,
“host”: “127.0.0.1”,
“apiVersion”: 2,
“showLog”: true,
“cwd”: “${workspaceFolder}”
}
参考
- [1] github-delv