Skip to content

Commit 28a6f9c

Browse files
Abirdcflygopherbot
authored andcommitted
cmd/go: add Context parameter to download function
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]>
1 parent 0394cbe commit 28a6f9c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/cmd/go/internal/get/get.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
170170
mode |= load.GetTestDeps
171171
}
172172
for _, pkg := range downloadPaths(args) {
173-
download(pkg, nil, &stk, mode)
173+
download(ctx, pkg, nil, &stk, mode)
174174
}
175175
base.ExitIfErrors()
176176

@@ -250,17 +250,17 @@ var downloadRootCache = map[string]bool{}
250250

251251
// download runs the download half of the get command
252252
// for the package or pattern named by the argument.
253-
func download(arg string, parent *load.Package, stk *load.ImportStack, mode int) {
253+
func download(ctx context.Context, arg string, parent *load.Package, stk *load.ImportStack, mode int) {
254254
if mode&load.ResolveImport != 0 {
255255
// Caller is responsible for expanding vendor paths.
256256
panic("internal error: download mode has useVendor set")
257257
}
258258
load1 := func(path string, mode int) *load.Package {
259259
if parent == nil {
260260
mode := 0 // don't do module or vendor resolution
261-
return load.LoadImport(context.TODO(), load.PackageOpts{}, path, base.Cwd(), nil, stk, nil, mode)
261+
return load.LoadImport(ctx, load.PackageOpts{}, path, base.Cwd(), nil, stk, nil, mode)
262262
}
263-
return load.LoadImport(context.TODO(), load.PackageOpts{}, path, parent.Dir, parent, stk, nil, mode|load.ResolveModule)
263+
return load.LoadImport(ctx, load.PackageOpts{}, path, parent.Dir, parent, stk, nil, mode|load.ResolveModule)
264264
}
265265

266266
p := load1(arg, mode)
@@ -403,7 +403,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
403403
if i >= len(p.Imports) {
404404
path = load.ResolveImportPath(p, path)
405405
}
406-
download(path, p, stk, 0)
406+
download(ctx, path, p, stk, 0)
407407
}
408408

409409
if isWildcard {

0 commit comments

Comments
 (0)