-
-
Notifications
You must be signed in to change notification settings - Fork 397
Open
Labels
Description
Consider this rewrite:
- slices.EqualFunc(c.Peers, o.Peers, func(a, b Peer) bool { return a.Equal(b) })
+ slices.EqualFunc(c.Peers, o.Peers, Peer.Equal)The former used an unnecessary anonymous function that could instead directly used the method expression.
This is rewrite is relatively trivial to statically detect where you have function of N input arguments and M output arguments and the body includes a single return expression calling a method on the first argument with N-1 input arguments.
I considered filing this in the golang/go issue tracker as a go/vet finding, but it's not a correctness bug, but rather a cleanliness "bug" that might be suited for staticcheck (where "simplicity" is listed one of the goals).