mirror of
https://github.com/golang/go
synced 2024-11-23 18:10:04 -07:00
cmd/go: adjust import config debugging flag
Change-Id: I3afaefc154f9ccfac353cedac7aefcfb70afe265 Reviewed-on: https://go-review.googlesource.com/86996 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
8396015e80
commit
dd806b8be4
@ -19,7 +19,8 @@ var DebugDeprecatedImportcfg debugDeprecatedImportcfgFlag
|
|||||||
|
|
||||||
type debugDeprecatedImportcfgFlag struct {
|
type debugDeprecatedImportcfgFlag struct {
|
||||||
enabled bool
|
enabled bool
|
||||||
pkgs map[string]*debugDeprecatedImportcfgPkg
|
Import map[string]string
|
||||||
|
Pkg map[string]*debugDeprecatedImportcfgPkg
|
||||||
}
|
}
|
||||||
|
|
||||||
type debugDeprecatedImportcfgPkg struct {
|
type debugDeprecatedImportcfgPkg struct {
|
||||||
@ -49,8 +50,9 @@ func (f *debugDeprecatedImportcfgFlag) Set(x string) error {
|
|||||||
}
|
}
|
||||||
data = data[len(debugDeprecatedImportcfgMagic):]
|
data = data[len(debugDeprecatedImportcfgMagic):]
|
||||||
|
|
||||||
f.pkgs = nil
|
f.Import = nil
|
||||||
if err := json.Unmarshal(data, &f.pkgs); err != nil {
|
f.Pkg = nil
|
||||||
|
if err := json.Unmarshal(data, &f); err != nil {
|
||||||
return errImportcfgSyntax
|
return errImportcfgSyntax
|
||||||
}
|
}
|
||||||
f.enabled = true
|
f.enabled = true
|
||||||
@ -58,18 +60,19 @@ func (f *debugDeprecatedImportcfgFlag) Set(x string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *debugDeprecatedImportcfgFlag) lookup(parent *Package, path string) (dir, newPath string) {
|
func (f *debugDeprecatedImportcfgFlag) lookup(parent *Package, path string) (dir, newPath string) {
|
||||||
if parent == nil {
|
newPath = path
|
||||||
if p1 := f.pkgs[path]; p1 != nil {
|
if p := f.Import[path]; p != "" {
|
||||||
return p1.Dir, path
|
newPath = p
|
||||||
}
|
|
||||||
return "", ""
|
|
||||||
}
|
}
|
||||||
if p1 := f.pkgs[parent.ImportPath]; p1 != nil {
|
if parent != nil {
|
||||||
if newPath := p1.Import[path]; newPath != "" {
|
if p1 := f.Pkg[parent.ImportPath]; p1 != nil {
|
||||||
if p2 := f.pkgs[newPath]; p2 != nil {
|
if p := p1.Import[path]; p != "" {
|
||||||
return p2.Dir, newPath
|
newPath = p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if p2 := f.Pkg[newPath]; p2 != nil {
|
||||||
|
return p2.Dir, newPath
|
||||||
|
}
|
||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user