-
Notifications
You must be signed in to change notification settings - Fork 516
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
Goose isn't thread safe? 🤔 #587
Comments
That's correct, there are parts of the public API that are not thread-safe, such as the global setters you've identified. In practice, most projects initialize goose settings once, so it won't be an issue. However, when using the goose library in go tests that run concurrently there will likely be issues if 2 goroutines are trying to set the global settings (as of now, v3.15.0, there are no mutexes). I would very much like to fix this by adding the concept of a I had a |
There could be an opportunity to add a lock within the goose package itself to protect the global setters, which would eliminate the race conditions. It's important to be aware that these operations involve modifying global settings. Using a setter function repeatedly might lead to unpredictable outcomes. Another way to resolve this issue involves the func TestMain() approach, which allows you to centralize all initialization tasks within a single location. |
We recently (v3.16.0 and higher) added a There's a bit more information in the Provider blog post: |
This is about functions
goose.SetLogger
andgoose.SetBaseFS
:The text was updated successfully, but these errors were encountered: