]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add Context parameter to download function
authorAbirdcfly <fp544037857@gmail.com>
Tue, 26 Jul 2022 06:43:48 +0000 (14:43 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 12 Oct 2022 14:36:26 +0000 (14:36 +0000)
Updates #38714

Change-Id: Ie5c7761ec003f84e649fa4c90be184a5ff6a0879
Reviewed-on: https://go-review.googlesource.com/c/go/+/419554
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/cmd/go/internal/get/get.go

index 586427ff33d698ad5ab6a16be61357ef3e4aae47..02289bf7f466ef7d3a9a92240c1d89adfbb4068a 100644 (file)
@@ -170,7 +170,7 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
                mode |= load.GetTestDeps
        }
        for _, pkg := range downloadPaths(args) {
-               download(pkg, nil, &stk, mode)
+               download(ctx, pkg, nil, &stk, mode)
        }
        base.ExitIfErrors()
 
@@ -250,7 +250,7 @@ var downloadRootCache = map[string]bool{}
 
 // download runs the download half of the get command
 // for the package or pattern named by the argument.
-func download(arg string, parent *load.Package, stk *load.ImportStack, mode int) {
+func download(ctx context.Context, arg string, parent *load.Package, stk *load.ImportStack, mode int) {
        if mode&load.ResolveImport != 0 {
                // Caller is responsible for expanding vendor paths.
                panic("internal error: download mode has useVendor set")
@@ -258,9 +258,9 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
        load1 := func(path string, mode int) *load.Package {
                if parent == nil {
                        mode := 0 // don't do module or vendor resolution
-                       return load.LoadImport(context.TODO(), load.PackageOpts{}, path, base.Cwd(), nil, stk, nil, mode)
+                       return load.LoadImport(ctx, load.PackageOpts{}, path, base.Cwd(), nil, stk, nil, mode)
                }
-               return load.LoadImport(context.TODO(), load.PackageOpts{}, path, parent.Dir, parent, stk, nil, mode|load.ResolveModule)
+               return load.LoadImport(ctx, load.PackageOpts{}, path, parent.Dir, parent, stk, nil, mode|load.ResolveModule)
        }
 
        p := load1(arg, mode)
@@ -403,7 +403,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
                        if i >= len(p.Imports) {
                                path = load.ResolveImportPath(p, path)
                        }
-                       download(path, p, stk, 0)
+                       download(ctx, path, p, stk, 0)
                }
 
                if isWildcard {