Skip to content

Commit dcc77f9

Browse files
wgrrgopherbot
authored andcommitted
cmd/go: fix get -tool when multiple packages are provided
Fixes #74035 Change-Id: I51865f4f753aade9a8be62ed6f9bc2d298742bf1 Reviewed-on: https://go-review.googlesource.com/c/go/+/679975 Reviewed-by: Ian Alexander <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Auto-Submit: Sean Liao <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Sean Liao <[email protected]>
1 parent c7b85e9 commit dcc77f9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func updateTools(ctx context.Context, queries []*query, opts *modload.WriteOpts)
453453
if queries[i].version == "none" {
454454
opts.DropTools = append(opts.DropTools, m.Pkgs...)
455455
} else {
456-
opts.AddTools = append(opts.DropTools, m.Pkgs...)
456+
opts.AddTools = append(opts.AddTools, m.Pkgs...)
457457
}
458458
}
459459
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Regression test for https://go.dev/issue/74035.
2+
go get -tool example.com/foo/cmd/a example.com/foo/cmd/b
3+
cmp go.mod go.mod.want
4+
5+
-- go.mod --
6+
module example.com/foo
7+
go 1.24
8+
-- go.mod.want --
9+
module example.com/foo
10+
11+
go 1.24
12+
13+
tool (
14+
example.com/foo/cmd/a
15+
example.com/foo/cmd/b
16+
)
17+
-- cmd/a/a.go --
18+
package a
19+
20+
func main() {}
21+
22+
-- cmd/b/b.go --
23+
package b
24+
25+
func main() {}

0 commit comments

Comments
 (0)