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
This commit is contained in:
David Symonds 2014-10-15 16:56:09 +11:00
parent 9be0b38f5b
commit 26439e8d81
1 changed files with 4 additions and 2 deletions

View File

@ -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 {