Type "beaconApiValidatorClient" has both value and pointer receivers
9 ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
10)
11
12func (c beaconApiValidatorClient) submitAttestations(ctx context.Context, attestations []*ethpb.Attestation) ([]*ethpb.AttestResponse, error) {13 for _, a := range attestations {
14 if err := checkNilAttestation(a); err != nil {
15 return nil, err
Description
(Go's FAQ)[https://go.dev/doc/faq#methodsonvaluesorpointers] recommends that method receivers should be consistent. 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. This is because value and pointer receivers have different method sets.
Bad practice
package main
type foo struct {
a int
}
func (f foo) a() {}
func (f *foo) b() {
f.a = 10
}
Recommended
package main
type foo struct {
a int
}
func (f *foo) a() {}
func (f *foo) b() {
f.a = 10
}