You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% cat abc.go
package main
import (
"fmt"
)
type Person struct {
name string
}
func (p *Person) String() string {
return p.name
}
func main() {
p := Person{name: "Gopher"}
fmt.Printf("%s\n", p.String())
}
% go vet abc.go
abc.go:17: redundant invocation of String method of p
It's not redundant, because String method requires a pointer receiver. So, *Person
implements the Stringer interface, but Person does not.
Following vet advice produces the wrong result: http://play.golang.org/p/CnXisy9MC_.