-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Instantiate mutexes by value #4632
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
base: master
Are you sure you want to change the base?
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
pkg/gui/types/common.go
Outdated
// if you add a new mutex here be sure to instantiate it. We're using pointers to | ||
// mutexes so that we can pass the mutexes to controllers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems to now be out of date, does its implications still apply?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, that was the whole point. Removed in 53d195f.
Instead, pass the entire Mutexes struct by pointer to controllers. This is better because Mutexes now has a zero value and doesn't need to be initialized.
Like in the previous commit, this is preferred because the fields don't need to be initialized this way.
58bf152
to
53d195f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Here's a minor cleanup: instantiate mutexes by value so that they don't have to be initialized explicitly. It is always preferable for structs to have a valid zero value, and this is one small step in that direction.
I read this recommendation in the Uber style guide, and it makes a lot of sense to me. I find most of the rest of this style guide to be a very good read, too.
go generate ./...
)