New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data race when using multiple unrelated cobra.Command
instances
#2109
Comments
This seems like the real issue, you will hit other issue depending on global state. Global state is fine for command line tools since they are a separate process. Of course Cobra would be more useful if multiple commands can run in parallel, but it probably require different interface that will make the normal use case harder to use. |
This short program causes data races when run with the race detector:
Is that expected? Is it just not supported to try and use multiple unrelated cobra.Command instances?
Our use case is that we're trying to test subsystems that are normally run as their own processes, without actually starting new processes (because of the difficulties in doing that in the Go test paradigm). We had hoped that these separate instances could run at the same time without causing problems, but it looks like they both try to add the members of the global
pflag.CommandLine
list as persistent flags.Is there a way to avoid this?
The text was updated successfully, but these errors were encountered: