]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: unexport loadImport
authorqiulaidongfeng <2645477756@qq.com>
Thu, 16 May 2024 22:44:16 +0000 (22:44 +0000)
committerMichael Matloob <matloob@golang.org>
Fri, 17 May 2024 00:11:59 +0000 (00:11 +0000)
Complete a TODO.

Change-Id: I39869df4d95a5a5f6019e281719b942fbf4ba7db
GitHub-Last-Rev: c664b5332e4f0afc84ae9bf1f91c0664903ebb7e
GitHub-Pull-Request: golang/go#67091
Reviewed-on: https://go-review.googlesource.com/c/go/+/581939
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/go/internal/load/pkg.go

index 4bf2f381dd04ea57bb81ef78fb3c6aa25276d6f4..92b1ea8d679c306b5d1b64ec8ee74d849d6ecfa8 100644 (file)
@@ -655,20 +655,6 @@ const (
        cmdlinePkgLiteral
 )
 
-// LoadImport scans the directory named by path, which must be an import path,
-// but possibly a local import path (an absolute file system path or one beginning
-// with ./ or ../). A local relative path is interpreted relative to srcDir.
-// It returns a *Package describing the package found in that directory.
-// LoadImport does not set tool flags and should only be used by
-// this package, as part of a bigger load operation, and by GOPATH-based "go get".
-// TODO(rsc): When GOPATH-based "go get" is removed, unexport this function.
-// The returned PackageError, if any, describes why parent is not allowed
-// to import the named package, with the error referring to importPos.
-// The PackageError can only be non-nil when parent is not nil.
-func LoadImport(ctx context.Context, opts PackageOpts, path, srcDir string, parent *Package, stk *ImportStack, importPos []token.Position, mode int) (*Package, *PackageError) {
-       return loadImport(ctx, opts, nil, path, srcDir, parent, stk, importPos, mode)
-}
-
 // LoadPackage does Load import, but without a parent package load contezt
 func LoadPackage(ctx context.Context, opts PackageOpts, path, srcDir string, stk *ImportStack, importPos []token.Position, mode int) *Package {
        p, err := loadImport(ctx, opts, nil, path, srcDir, nil, stk, importPos, mode)
@@ -678,6 +664,15 @@ func LoadPackage(ctx context.Context, opts PackageOpts, path, srcDir string, stk
        return p
 }
 
+// loadImport scans the directory named by path, which must be an import path,
+// but possibly a local import path (an absolute file system path or one beginning
+// with ./ or ../). A local relative path is interpreted relative to srcDir.
+// It returns a *Package describing the package found in that directory.
+// loadImport does not set tool flags and should only be used by
+// this package, as part of a bigger load operation.
+// The returned PackageError, if any, describes why parent is not allowed
+// to import the named package, with the error referring to importPos.
+// The PackageError can only be non-nil when parent is not nil.
 func loadImport(ctx context.Context, opts PackageOpts, pre *preload, path, srcDir string, parent *Package, stk *ImportStack, importPos []token.Position, mode int) (*Package, *PackageError) {
        ctx, span := trace.StartSpan(ctx, "modload.loadImport "+path)
        defer span.Done()
@@ -1971,7 +1966,7 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk *
                if path == "C" {
                        continue
                }
-               p1, err := LoadImport(ctx, opts, path, p.Dir, p, stk, p.Internal.Build.ImportPos[path], ResolveImport)
+               p1, err := loadImport(ctx, opts, nil, path, p.Dir, p, stk, p.Internal.Build.ImportPos[path], ResolveImport)
                if err != nil && p.Error == nil {
                        p.Error = err
                        p.Incomplete = true
@@ -2696,7 +2691,7 @@ func TestPackageList(ctx context.Context, opts PackageOpts, roots []*Package) []
        }
        walkTest := func(root *Package, path string) {
                var stk ImportStack
-               p1, err := LoadImport(ctx, opts, path, root.Dir, root, &stk, root.Internal.Build.TestImportPos[path], ResolveImport)
+               p1, err := loadImport(ctx, opts, nil, path, root.Dir, root, &stk, root.Internal.Build.TestImportPos[path], ResolveImport)
                if err != nil && root.Error == nil {
                        // Assign error importing the package to the importer.
                        root.Error = err
@@ -2724,7 +2719,7 @@ func TestPackageList(ctx context.Context, opts PackageOpts, roots []*Package) []
 // TODO(jayconrod): delete this function and set flags automatically
 // in LoadImport instead.
 func LoadImportWithFlags(path, srcDir string, parent *Package, stk *ImportStack, importPos []token.Position, mode int) (*Package, *PackageError) {
-       p, err := LoadImport(context.TODO(), PackageOpts{}, path, srcDir, parent, stk, importPos, mode)
+       p, err := loadImport(context.TODO(), PackageOpts{}, nil, path, srcDir, parent, stk, importPos, mode)
        setToolFlags(p)
        return p, err
 }