Type "gdstate" has both value and pointer receivers
99 return toStr(g)
100}
101
102func (g gdstate) String() string { 103 var r []string
104 for _, s := range g.gstates {
105 r = append(r, s.String())
Type "gdstate" has both value and pointer receivers
107 return strings.Join(r, ",")
108}
109
110func (g *gdstate) step(c byte) *gdstate { 111 // if g.next[c] != nil {
112 // g.cacheHit++
113 // return g.next[c]
Type "gdstate" has both value and pointer receivers
125 return &ng
126}
127
128func (g *gdstate) add(list []*gstate, s *gstate) []*gstate { 129 if s.c[gstateSplit] {
130 for _, ns := range s.next {
131 list = g.add(list, ns)
Type "gdstate" has both value and pointer receivers
138 return list
139}
140
141func (g *gdstate) matched() bool { 142 for _, s := range g.gstates {
143 if s == endGstate {
144 return true
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
}