diff options
author | Jay Conrod <jayconrod@google.com> | 2019-03-15 13:41:48 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-04-01 13:50:27 +0000 |
commit | d6b2b35e641eeac9f764d21dcaed46973b3e2720 (patch) | |
tree | 49c05f207d4db79fe4a8540616436fe1399d5341 /src/cmd/go/internal/get/get.go | |
parent | 4091cf972a37418c847426bd15709cd0128fad81 (diff) | |
download | go-d6b2b35e641eeac9f764d21dcaed46973b3e2720.tar.gz go-d6b2b35e641eeac9f764d21dcaed46973b3e2720.zip |
cmd/go: refactor load.LoadPackage into other functions
LoadPackage was used to load a *load.Package for a command line
argument, after pattern expansion. It provided two special cases on
top of LoadImport. First, it ensured that "cmd/" packages in GOROOT
were installed in "$GOROOT/bin" or "$GOROOT/pkg/tool". Second, it
translated absolute paths to packages in GOROOT and GOPATH into
regular import paths.
With this change, LoadImport now ensures "cmd/" packages have the
right Target (without the need for a special case) and
search.ImportPaths translates absolute paths.
LoadPackage no longer handles these special cases and has been renamed
to LoadImportWithFlags, since it's still useful for loading implicit
dependencies.
Updates #29758
Change-Id: I9d54036f90c3ccd9b3a0fe0eaddaa7749593cc91
Reviewed-on: https://go-review.googlesource.com/c/go/+/167748
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/get/get.go')
-rw-r--r-- | src/cmd/go/internal/get/get.go | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/cmd/go/internal/get/get.go b/src/cmd/go/internal/get/get.go index a314c57160..fe15515efc 100644 --- a/src/cmd/go/internal/get/get.go +++ b/src/cmd/go/internal/get/get.go @@ -177,12 +177,6 @@ func runGet(cmd *base.Command, args []string) { // everything. load.ClearPackageCache() - // In order to rebuild packages information completely, - // we need to clear commands cache. Command packages are - // referring to evicted packages from the package cache. - // This leads to duplicated loads of the standard packages. - load.ClearCmdCache() - pkgs := load.PackagesForBuild(args) // Phase 3. Install. @@ -240,7 +234,8 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int) } load1 := func(path string, mode int) *load.Package { if parent == nil { - return load.LoadPackageNoFlags(path, stk) + mode := 0 // don't do module or vendor resolution + return load.LoadImport(path, base.Cwd, nil, stk, nil, mode) } return load.LoadImport(path, parent.Dir, parent, stk, nil, mode|load.ResolveModule) } |