-
Notifications
You must be signed in to change notification settings - Fork 648
debug the golang project use root privilege #2889
Comments
@jhendrixMSFT, @quoctruong thoughts? |
@calmkart Another alternative you can consider is to launch the program with |
Expanding on what @quoctruong suggested ... I got a tip from somewhere else on a way to do this, which I adapted for a project of mine: Use a wrapper script to invoke For example, in a repo of mine I have: {
"go.alternateTools": {
"dlv": "${workspaceFolder}/.vscode/dlv-sudo.sh"
}
} and #!/bin/sh
if ! which dlv ; then
PATH="${GOPATH}/bin:$PATH"
fi
if [ "$DEBUG_AS_ROOT" = "true" ]; then
exec sudo dlv "$@"
else
exec dlv "$@"
fi (don't forget to And finally, for the launch task(s) that need root: {
"version": "0.2.0",
"configurations": [
{
"name": "Run as root",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"env": {
"DEBUG_AS_ROOT": "true",
}
// etc...
}
]
} |
@quoctruong: Does this issue still need further discussion or is this working as intended? |
It's working as intended. Adding |
Makes sense. #2610 is a duplicate that mentions debugging with root privileges remotely - is there a work-around for that? |
I think the work around by starting the remote dlv session with |
Sounds good. @ramya-rao-a: Should this issue be closed or left open for others to find? |
@ramya-rao-a I think this issue can be closed since the workaround is available and we don't want to add extra field to the current debug configuration. |
Unfortunately, the above mentioned remedy doesn't work out of the box any more, or it lacks some sudo configuration I'm not aware of. Also, running dlv as sudo without
|
@thediveo If you are still seeing problems, please log a new issue at https://github.com/golang/vscode-go as we are moving |
Is your feature request related to a problem? Please describe.
i want to debug a golang project in vscode, but the project need root privilege(i can run my project "sudo go main.go").the vscode debug launch.json for golang has no privilege settings.i try to find a way to debug in root, but there is not a easy method.
Describe the solution you'd like
add a root privilege settings option in golang launch.json like python debug.
Describe alternatives you've considered
run vscode in root privilege(sudo run vscode), but i don't think it's a good solution.
Additional context
None
The text was updated successfully, but these errors were encountered: