-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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 -modfile and -modcacherw to go tool
When adding support for module tools, we added the ability for `go tool` to edit the module cache. For users with `GOFLAGS=-modcacherw` this could have led to a situation where some of the files in the mod cache were unexpectedly not deletable. We also allow -modfile so that people can select which module they are working in when looking for tools. We still do not support arbitrary build flags for tools with `go tool`. If you want those, use `go run` or `go build`, etc. instead. Updates #48429 Change-Id: Ic3c56bb8b6ba46114196465ca6ee2dcb08b9dcc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/632575 Reviewed-by: Michael Matloob <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
- Loading branch information
1 parent
d3d4e7b
commit ec7817e
Showing
3 changed files
with
14 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -42,6 +42,15 @@ cp $WORK/extraneous.txt $GOPATH/pkg/mod/rsc.io/[email protected]/extraneous_file.go | |
! go mod verify | ||
[!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/rsc.io/[email protected]/go.mod | ||
|
||
# Repeat part of the test with 'go tool' | ||
go mod edit -tool example.com/tools/cmd/hello -require example.com/[email protected] | ||
go mod download -modcacherw example.com/tools | ||
go clean -modcache | ||
go tool -modcacherw hello | ||
cp $WORK/extraneous.txt $GOPATH/pkg/mod/example.com/[email protected]/extraneous_file.go | ||
! go mod verify | ||
[!root] ! cp $WORK/extraneous.txt $GOPATH/pkg/mod/example.com/[email protected]/cmd/hello/hello.go | ||
|
||
|
||
-- $WORK/extraneous.txt -- | ||
module oops | ||
|
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 |
---|---|---|
|
@@ -48,6 +48,10 @@ go build -n -mod=mod . | |
go test -n -mod=mod . | ||
go get rsc.io/quote | ||
|
||
# 'go tool' and tool management should work. | ||
go get -tool example.com/tools/cmd/[email protected] | ||
grep cmd/hello go.alt.mod | ||
go tool hello | ||
|
||
# 'go mod vendor' should work. | ||
go mod vendor | ||
|