diff --git a/cmd/vet/types.go b/cmd/vet/types.go index 5c9fc89a..45c20b03 100644 --- a/cmd/vet/types.go +++ b/cmd/vet/types.go @@ -20,10 +20,17 @@ var imports = make(map[string]*types.Package) var ( stringerMethodType = types.New("func() string") errorType = types.New("error").Underlying().(*types.Interface) - stringerType = importType("fmt", "Stringer").Underlying().(*types.Interface) - formatterType = importType("fmt", "Formatter").Underlying().(*types.Interface) + stringerType = types.New("interface{ String() string }").(*types.Interface) + formatterType *types.Interface ) +func init() { + typ := importType("fmt", "Formatter") + if typ != nil { + formatterType = typ.Underlying().(*types.Interface) + } +} + // importType returns the type denoted by the qualified identifier // path.name, and adds the respective package to the imports map // as a side effect.