golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 728 forks source link

Ability to run tests with root priviliges #3257

Closed SaadAhmedGit closed 3 months ago

SaadAhmedGit commented 3 months ago

Is your feature request related to a problem? Please describe. My program has to interact with wireguard thus it needs to have root privileges.

Describe the solution you'd like Some way to configure privileges when running tests. It can ask for sudo password and then run the tests as root.

Describe alternatives you've considered Running the tests from command line with sudo.

findleyr commented 3 months ago

CC @hyangah

Thank you for the issue. Given that this is a rare need, there's an existing workaround (run from the command line), and it would require a new UI and has perhaps complicated security implications, I would not be surprised if this does not get prioritized soon.

hyangah commented 3 months ago

https://github.com/golang/vscode-go/wiki/debugging#launchjson-attributes

See asRoot. You will need to configure launch.json configuration.

findleyr commented 3 months ago

@hyangah I saw that (or rather, the related issue), but thought it applied only to debug. Does it apply to run as well?

SaadAhmedGit commented 3 months ago

@hyangah I saw that (or rather, the related issue), but thought it applied only to debug. Does it apply to run as well?

You're right. It only applies to debugging and is not available in tasks.json

hyangah commented 3 months ago

You can define your own tasks.json that invokes sudo and necessary arguments. Or, you can use launch.json but use ^+F5 (ironic "Debug: Start Without Debugging").

However, as @findleyr said, allowing to easily run tests as a root has security implication, and may result in undesirable side effects. Given this is not frequently needed nor desirable, I agree we won't prioritize this.

adonovan commented 3 months ago

For security reasons this doesn't seem like a problem we should attempt to solve in VS Code. Closing as infeasible.