Skip to content
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

Fix data race in keyboard.Listen() and unit tests, enable race detection #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gheinrich-dd
Copy link

Motivation

There's currently a data race as described here. This makes it hard to enable data race detection for projects using this package. I'm implementing a possible solution using the atomic.Bool wrapper and enabling race detection via -race for go tests. I also had to wrap appending to the slice in a unit test with a lock to fix another data race issue. One caveat of this solution is that using atomic.Bool requires a minimum go version of 1.19.

@gheinrich-dd
Copy link
Author

If bumping to go 1.19 is not desired, I could also change it to wrap access to the shared variable with sync.Mutex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant