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
type S struct {
_ func() // not printable with %s
}
func (S) String() string
var _, _ = fmt.Printf("%s", S{})
% vet ./stringer.go
% GOROOT=/nosuchdir vet ./stringer.go
vet: import failed: can't find import: fmt
vet: import failed: can't find import: fmt
./stringer.go:11: arg S{} for printf verb %s of wrong type: p.S
David, I believe this is the root cause of internal bug #13114430. We might want to create the stringerType interface from whole cloth instead of loading it. Or not; perhaps this bug is too obscure.
The text was updated successfully, but these errors were encountered:
fmt.Stringer is certainly a trivial enough type, yet central enough to vet's operation that it seems correct to manifest it within vet. I'm not sure how to do that, but happy to review a CL from you.
ianlancetaylor
changed the title
vet: failure to load "fmt" causes spurious fmt.Stringer errors
cmd/vet: failure to load "fmt" causes spurious fmt.Stringer errors
Nov 5, 2015
We could "fix" this by changing the external tool, but that's unsatisfactory for two reasons. (1) External users are very unlikely to encounter this problem because their GOROOT will be either unset or set to a valid directory. Effectively we'd be adding a bizarre new invariant to the external code base, namely that the tool must work without access to the standard library. (2) Even if we hand-code the Stringer type, the tool has dependencies on other standard types like fmt.Formatter that mention named types, and it may grow more in the future. The same workaround won't work for them.
So I think the right place for the fix is in [our internal tools, to set GOROOT correctly.].
% cat stringer.go
package p
import "fmt"
type S struct {
_ func() // not printable with %s
}
func (S) String() string
var _, _ = fmt.Printf("%s", S{})
% vet ./stringer.go
% GOROOT=/nosuchdir vet ./stringer.go
vet: import failed: can't find import: fmt
vet: import failed: can't find import: fmt
./stringer.go:11: arg S{} for printf verb %s of wrong type: p.S
David, I believe this is the root cause of internal bug #13114430. We might want to create the stringerType interface from whole cloth instead of loading it. Or not; perhaps this bug is too obscure.
The text was updated successfully, but these errors were encountered: