赞
踩
场景:
golang代码在ubuntu上,
vscode在windows上。
方法:
1 打开vscode
2 左侧栏-》远程资源管理器。设置SSH远端到ubuntu上。选择配置为linux
3 双击2中创建的SSH远端,进入文件选择,选择golang代码。
4 双击打开的3中的文件夹,vscode打开main.go
cmd/vpp-agent/main.go
5 左侧栏-》运行和调试。选择launch package,其右侧”设置“按钮,打开之。会创建一个默认的launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args":["-logs-config=/etc/vpp-agent/conf.d/logs.conf","-grpc-config=/etc/vpp-agent/conf.d/grpc.conf", "-etcd-config=/etc/vpp-agent/conf.d/etcd.conf", "-telemetry-config=/etc/vpp-agent/conf.d/telemetry.conf", "-govpp-config=/etc/vpp-agent/conf.d/govpp.conf", "-vpp-ifplugin-config=/etc/vpp-agent/conf.d/vpp-ifplugin.conf", "-linux-ifplugin-config=/etc/vpp-agent/conf.d/linux-ifplugin.conf", "-linux-iptablesplugin-config=/etc/vpp-agent/conf.d/linux-iptablesplugin.conf", "-linux-l3plugin-config=/etc/vpp-agent/conf.d/linux-l3plugin.conf", "-linux-nsplugin-config=/etc/vpp-agent/conf.d/linux-nsplugin.conf"]
}
]
}
如果需要带参数调试,就在args里面加。这里面是列表[]
6 选中main.go,双击文件内容行的侧边可加断点。选中左侧栏-》运行和调试.选择launch package,按播放按钮(侧三角)就可以调试golang代码。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。