1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:34:53 -07:00

go.tools/cmd/godex: don't generate prefixes for local and absolute path arguments

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/81340047
This commit is contained in:
Robert Griesemer 2014-03-28 14:59:25 -07:00
parent 1faba6e3b8
commit 7e60d06cfc

View File

@ -64,9 +64,9 @@ func main() {
logf("\tprocessing %q: path = %q, name = %s\n", arg, path, name)
// generate possible package path prefixes
// (at the moment we do this for each argument - should probably cache this)
// (at the moment we do this for each argument - should probably cache the generated prefixes)
prefixes := make(chan string)
go genPrefixes(prefixes)
go genPrefixes(prefixes, !filepath.IsAbs(path) && !build.IsLocalImport(path))
// import package
pkg, err := tryPrefixes(packages, prefixes, path, imp)
@ -172,12 +172,14 @@ func lookup(src string) types.Importer {
return nil
}
func genPrefixes(out chan string) {
out <- "" // try no prefix
platform := build.Default.GOOS + "_" + build.Default.GOARCH
dirnames := append([]string{build.Default.GOROOT}, filepath.SplitList(build.Default.GOPATH)...)
for _, dirname := range dirnames {
walkDir(filepath.Join(dirname, "pkg", platform), "", out)
func genPrefixes(out chan string, all bool) {
out <- ""
if all {
platform := build.Default.GOOS + "_" + build.Default.GOARCH
dirnames := append([]string{build.Default.GOROOT}, filepath.SplitList(build.Default.GOPATH)...)
for _, dirname := range dirnames {
walkDir(filepath.Join(dirname, "pkg", platform), "", out)
}
}
close(out)
}