From 26439e8d81646959903b2904e02dbf3ab12eb122 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Wed, 15 Oct 2014 16:56:09 +1100 Subject: [PATCH] cmd/vet: return nil from importType if it fails. This permits vet to not panic during init if fmt.a is unavailable. LGTM=r R=gri, r CC=golang-codereviews https://golang.org/cl/153590043 --- cmd/vet/types.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/vet/types.go b/cmd/vet/types.go index 45c20b03..9f762dd5 100644 --- a/cmd/vet/types.go +++ b/cmd/vet/types.go @@ -37,12 +37,14 @@ func init() { func importType(path, name string) types.Type { pkg, err := types.DefaultImport(imports, path) if err != nil { - panic("import failed: " + err.Error()) + warnf("import failed: %v", err) + return nil } if obj, ok := pkg.Scope().Lookup(name).(*types.TypeName); ok { return obj.Type() } - panic("invalid type name: " + name) + warnf("invalid type name %q", name) + return nil } func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) error {