Type "ConfigType" has both value and pointer receivers
136 }
137}
138
139func (c *ConfigType) SetZipper(zipper zipper.CarbonZipper) (err error) {140 c.ZipperInstance = zipper
141 c.Evaluator, err = expr.NewEvaluator(c.Limiter, c.ZipperInstance)
142 return
Type "ConfigType" has both value and pointer receivers
127}
128
129// skipcq: CRT-P0003
130func (c ConfigType) String() string {131 data, err := json.Marshal(c)
132 if err != nil {
133 return "Failed to marshal config: " + err.Error()
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
}