Skip to content

Commit

Permalink
cmd/go: add Context parameter to download function
Browse files Browse the repository at this point in the history
Updates #38714

Change-Id: Ie5c7761ec003f84e649fa4c90be184a5ff6a0879
Reviewed-on: https://go-review.googlesource.com/c/go/+/419554
Reviewed-by: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Bryan Mills <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
Reviewed-by: Joedian Reid <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
  • Loading branch information
Abirdcfly authored and gopherbot committed Oct 12, 2022
1 parent 0394cbe commit 28a6f9c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cmd/go/internal/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -250,17 +250,17 @@ 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")
}
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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 28a6f9c

Please sign in to comment.