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

.golangci.yml: enable recvcheck #5758

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

tarasmadan
Copy link
Collaborator

@tarasmadan tarasmadan commented Feb 6, 2025

The plan was to make a few trivial fixes, but something went wrong...

@tarasmadan tarasmadan marked this pull request as ready for review February 6, 2025 14:13
@dvyukov
Copy link
Collaborator

dvyukov commented Feb 6, 2025

What is it checking? What are the warning? Is it fixing bugs, or style?

Lots of semantic changes, some are affecting performance, but unclear why the new code is better.

@tarasmadan
Copy link
Collaborator Author

Is it fixing bugs, or style?

Short answer - mostly style.
The recommendation is to make all receivers *T or T and to not mix them.
Dave Chaney also mentioned the data races which are happening when you write to some field in goroutine using *T and call some T method which reads the field.

https://go.dev/doc/faq#methods_on_values_or_pointers

_Next is consistency. If some of the methods of the type must have pointer receivers, the rest should too, so the method set is consistent regardless of how the type is used. See the section on method sets for details.

For types such as basic types, slices, and small structs, a value receiver is very cheap so unless the semantics of the method requires a pointer, a value receiver is efficient and clear._

https://dave.cheney.net/2016/03/19/should-methods-be-declared-on-t-or-t

@tarasmadan
Copy link
Collaborator Author

#5761 to only delete unused

pkg/signal/signal.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@dvyukov dvyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look fine to me, I will defer to Aleksandr since it touches prog expressions code.

@tarasmadan tarasmadan force-pushed the recvcheck_enable branch 13 times, most recently from 0e7c5e2 to 35d6020 Compare February 7, 2025 11:03
@tarasmadan tarasmadan enabled auto-merge February 7, 2025 15:24
@tarasmadan tarasmadan added this pull request to the merge queue Feb 7, 2025
Merged via the queue into google:master with commit ef44b75 Feb 7, 2025
17 checks passed
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.

3 participants