-
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: enter vendor mode depending on new modules.txt workspace line
modules.txt gets a new ## workspace line at the start of the file if it's generated in workspace mode. Then, when deciding whether the go command runs in mod=vendor, we only do so if we're in the same mode (workspace or not) as the modules.txt specifies. For #60056 Change-Id: If478a9891a7135614326fcb80c4c33a431e4e531 Reviewed-on: https://go-review.googlesource.com/c/go/+/513756 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
- Loading branch information
Showing
6 changed files
with
128 additions
and
10 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
62 changes: 62 additions & 0 deletions
62
src/cmd/go/testdata/script/work_vendor_modules_txt_conditional.txt
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,62 @@ | ||
# This test checks to see if we only start in workspace vendor | ||
# mode if the modules.txt specifies ## workspace (and only in | ||
# standard vendor if it doesn't). | ||
|
||
# vendor directory produced for workspace, workspace mode | ||
# runs in mod=vendor | ||
go work vendor | ||
cmp vendor/modules.txt want_workspace_modules_txt | ||
go list -f {{.Dir}} example.com/b | ||
stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b | ||
|
||
# vendor directory produced for workspace, module mode | ||
# runs in mod=readonly | ||
env GOWORK=off | ||
go list -f {{.Dir}} example.com/b | ||
stdout $GOPATH[\\/]src[\\/]b | ||
|
||
# vendor directory produced for module, module mode | ||
# runs in mod=vendor | ||
go mod vendor | ||
cmp vendor/modules.txt want_module_modules_txt | ||
go list -f {{.Dir}} example.com/b | ||
stdout $GOPATH[\\/]src[\\/]vendor[\\/]example.com[\\/]b | ||
|
||
# vendor directory produced for module, workspace mode | ||
# runs in mod=readonly | ||
env GOWORK= | ||
go list -f {{.Dir}} example.com/b | ||
stdout $GOPATH[\\/]src[\\/]b | ||
|
||
-- want_workspace_modules_txt -- | ||
## workspace | ||
# example.com/b v0.0.0 => ./b | ||
## explicit; go 1.21 | ||
example.com/b | ||
# example.com/b => ./b | ||
-- want_module_modules_txt -- | ||
# example.com/b v0.0.0 => ./b | ||
## explicit; go 1.21 | ||
example.com/b | ||
# example.com/b => ./b | ||
-- go.work -- | ||
go 1.21 | ||
|
||
use . | ||
-- go.mod -- | ||
module example.com/a | ||
|
||
go 1.21 | ||
|
||
require example.com/b v0.0.0 | ||
replace example.com/b => ./b | ||
-- a.go -- | ||
package a | ||
|
||
import _ "example.com/b" | ||
-- b/go.mod -- | ||
module example.com/b | ||
|
||
go 1.21 | ||
-- b/b.go -- | ||
package b |
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