-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: add support for go get -tool
Running `go get -tool example.com/m1` will add a tool line to your mod file and add any missing dependencies. Running `go get -tool example.com/m1@none` will drop the tool line from your mod file. For #48429 Change-Id: I07b4776f1f55eff588d08cb6649d94cc42a729d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/563175 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
- Loading branch information
1 parent
03fecda
commit 68bcef7
Showing
4 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# test go get -tool | ||
go get -tool example.com/tools/cmd/hello | ||
cmp go.mod go.mod.want | ||
|
||
# test -tool with @none | ||
go get -tool example.com/tools/cmd/hello@none | ||
cmp go.mod go.mod.gone | ||
|
||
go mod tidy | ||
cmp go.mod go.mod.empty | ||
|
||
# test -tool with wildcards | ||
go get -tool ./cmd/... | ||
cmp go.mod go.mod.wildcard | ||
! go get -tool ./cmd/...@none | ||
stderr 'can''t request explicit version "none" of path "./cmd/..." in main module' | ||
|
||
# test -tool with all | ||
! go get -tool all | ||
stderr 'go get -tool does not work with "all"' | ||
|
||
-- main.go -- | ||
package main | ||
|
||
func main() {} | ||
|
||
-- go.mod -- | ||
module example.com/foo | ||
go 1.24 | ||
|
||
-- go.mod.want -- | ||
module example.com/foo | ||
|
||
go 1.24 | ||
|
||
tool example.com/tools/cmd/hello | ||
|
||
require example.com/tools v1.0.0 // indirect | ||
-- go.mod.gone -- | ||
module example.com/foo | ||
|
||
go 1.24 | ||
|
||
require example.com/tools v1.0.0 // indirect | ||
-- go.mod.empty -- | ||
module example.com/foo | ||
|
||
go 1.24 | ||
-- go.mod.wildcard -- | ||
module example.com/foo | ||
|
||
go 1.24 | ||
|
||
tool ( | ||
example.com/foo/cmd/a | ||
example.com/foo/cmd/b | ||
) | ||
-- cmd/a/a.go -- | ||
package a | ||
|
||
func main() {} | ||
|
||
-- cmd/b/b.go -- | ||
package b | ||
|
||
func main() {} |