Change-Id: Iedbe47d087d17984a9d839c13c4b7e6c1fa0deaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/338594
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
// wasn't provided. setDefaultBuildMod may be called multiple times.
func setDefaultBuildMod() {
if cfg.BuildModExplicit {
- if inWorkspaceMode() {
- base.Fatalf("go: -mod can't be set explicitly when in workspace mode." +
+ if inWorkspaceMode() && cfg.BuildMod != "readonly" {
+ base.Fatalf("go: -mod may only be set to readonly when in workspace mode." +
"\n\tRemove the -mod flag to use the default readonly value," +
"\n\tor set -workfile=off to disable workspace mode.")
}
stdout 'example.com/a'
stdout 'example.com/b'
-# -mod can't be set in workspace mode, even to readonly
-! go list -mod=readonly all
-stderr '^go: -mod can''t be set explicitly'
-go list -mod=readonly -workfile=off all
+# -mod can only be set to readonly in workspace mode
+go list -mod=readonly all
+! go list -mod=mod all
+stderr '^go: -mod may only be set to readonly when in workspace mode'
+go list -mod=mod -workfile=off all
# Test that duplicates in the directory list return an error
cp go.work go.work.backup