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_.
The text was updated successfully, but these errors were encountered:
Yeah, I have also tripped over this. It could use the typechecker a little more to work
out whether p has the method on that type, but maybe this is just overstepping govet's
purview.
Give me a day to think about it.
The text was updated successfully, but these errors were encountered: