How can I force Delve in VS Code to use root privileges?
I'm trying to debug go file that involves gopacket/pcap:
hndl, err := pcapgo.NewEthernetHandle(ifname)
// err == "couldn't open packet socket: operation not permitted"
Launching same program using sudo doesn't trigger error.
I've tried several methods:
- Launch
sudo code .It warns that it is not recommended. Plus there are issues to use dlv in this mode as environment variables are messed up. - Using this guide https://fatdragon.me/blog/2020/06/debug-golang-vs-code-linux-root. However
"go.alternateTools"seems to know nothing about "dlv":Property dlv is not allowed.Probably something is missing in guide. - Search for
.vscode/launch.jsonconfig property that allows to sudo. VSC allows to do such for Python, but not for Go.
Is there any trivial way to launch debugger with root privileges?
Environment:
- Ubuntu 18.04
- VSCode 1.48.0
- Go 1.13.4
- Delve 1.4.0