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:
parent
9be0b38f5b
commit
26439e8d81
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue