aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-06-16 14:48:45 -0400
committerBryan C. Mills <bcmills@google.com>2021-06-21 14:10:22 +0000
commit117ebe0f52efc5128a9c86722e07fe22cb65450d (patch)
tree49de83aa7fe2afc33e6aa6d77d8705d4ea3d69a4 /src
parent460900a7b51f917888cb17608367979243178fe1 (diff)
downloadgo-117ebe0f52efc5128a9c86722e07fe22cb65450d.tar.xz
cmd/go: do not require the module cache to exist for 'go mod edit'
Updates #46695 Change-Id: I4afbc1401ef4183d94c1ac6271394fac1fff95ae Reviewed-on: https://go-review.googlesource.com/c/go/+/328769 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/internal/modfetch/cache.go2
-rw-r--r--src/cmd/go/testdata/script/mod_edit_no_modcache.txt15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modfetch/cache.go b/src/cmd/go/internal/modfetch/cache.go
index f3b58a172a..b01b467413 100644
--- a/src/cmd/go/internal/modfetch/cache.go
+++ b/src/cmd/go/internal/modfetch/cache.go
@@ -152,7 +152,7 @@ func lockVersion(mod module.Version) (unlock func(), err error) {
// If err is nil, the caller MUST eventually call the unlock function.
func SideLock() (unlock func(), err error) {
if err := checkCacheDir(); err != nil {
- base.Fatalf("go: %v", err)
+ return nil, err
}
path := filepath.Join(cfg.GOMODCACHE, "cache", "lock")
diff --git a/src/cmd/go/testdata/script/mod_edit_no_modcache.txt b/src/cmd/go/testdata/script/mod_edit_no_modcache.txt
new file mode 100644
index 0000000000..ced15bb301
--- /dev/null
+++ b/src/cmd/go/testdata/script/mod_edit_no_modcache.txt
@@ -0,0 +1,15 @@
+# 'go mod edit' opportunistically locks the side-lock file in the module cache,
+# for compatibility with older versions of the 'go' command.
+# It does not otherwise depend on the module cache, so it should not
+# fail if the module cache directory cannot be created.
+
+[root] skip
+
+mkdir $WORK/readonly
+chmod 0555 $WORK/readonly
+env GOPATH=$WORK/readonly/nonexist
+
+go mod edit -go=1.17
+
+-- go.mod --
+module example.com/m