]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: inline doImport into doPkg
authorBryan C. Mills <bcmills@google.com>
Wed, 25 Jul 2018 18:55:42 +0000 (14:55 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 31 Jul 2018 02:00:47 +0000 (02:00 +0000)
doImport is itself a thin wrapper around Import, and doPkg is its only call
site. I'm having trouble following what doPkg is doing due to the indirection,
so I'm removing it.

Change-Id: I6167be68e869a36010a56a5869df50b1145ac813
Reviewed-on: https://go-review.googlesource.com/125837
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/internal/modload/load.go

index dd8a60eb0933d204fefbeaeed4d4121288ee3f07..36dc0deee7818a2aef62fa574aa197488b26c9a3 100644 (file)
@@ -494,7 +494,17 @@ func (ld *loader) doPkg(item interface{}) {
                pkg.mod = pkg.testOf.mod
                imports = pkg.testOf.testImports
        } else {
-               pkg.mod, pkg.dir, pkg.err = ld.doImport(pkg.path)
+               if strings.Contains(pkg.path, "@") {
+                       // Leave for error during load.
+                       return
+               }
+               if build.IsLocalImport(pkg.path) {
+                       // Leave for error during load.
+                       // (Module mode does not allow local imports.)
+                       return
+               }
+
+               pkg.mod, pkg.dir, pkg.err = Import(pkg.path)
                if pkg.dir == "" {
                        return
                }
@@ -526,26 +536,6 @@ func (ld *loader) doPkg(item interface{}) {
        }
 }
 
-// doImport finds the directory holding source code for the given import path.
-// It returns the module containing the package (if any),
-// the directory containing the package (if any),
-// and any error encountered.
-// Not all packages have modules: the ones in the standard library do not.
-// Not all packages have directories: "unsafe" and "C" do not.
-func (ld *loader) doImport(path string) (mod module.Version, dir string, err error) {
-       if strings.Contains(path, "@") {
-               // Leave for error during load.
-               return module.Version{}, "", nil
-       }
-       if build.IsLocalImport(path) {
-               // Leave for error during load.
-               // (Module mode does not allow local imports.)
-               return module.Version{}, "", nil
-       }
-
-       return Import(path)
-}
-
 // scanDir is like imports.ScanDir but elides known magic imports from the list,
 // so that we do not go looking for packages that don't really exist.
 //