1
0
mirror of https://github.com/golang/go synced 2024-09-30 20:18:33 -06:00

go/types: don't panic if DefaultImport==nil, until we actually use it.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/178860044
This commit is contained in:
Alan Donovan 2014-11-17 15:24:12 -05:00
parent 89c9513804
commit 0088b7ecd7
2 changed files with 7 additions and 5 deletions

View File

@ -130,10 +130,14 @@ func (check *Checker) collectObjects() {
importer := check.conf.Import
if importer == nil {
if DefaultImport == nil {
panic(`no Config.Import or DefaultImport (missing import _ "golang.org/x/tools/go/gcimporter"?)`)
if DefaultImport != nil {
importer = DefaultImport
} else {
// Panic if we encounter an import.
importer = func(map[string]*Package, string) (*Package, error) {
panic(`no Config.Import or DefaultImport (missing import _ "golang.org/x/tools/go/gcimporter"?)`)
}
}
importer = DefaultImport
}
// pkgImports is the set of packages already imported by any package file seen

View File

@ -10,8 +10,6 @@ import (
"golang.org/x/tools/go/types"
"golang.org/x/tools/go/types/typeutil"
_ "golang.org/x/tools/go/gcimporter" // no imports; why is this necessary?
)
func ExampleMap() {