Skip to content

Commit

Permalink
cmd/go: do not require the module cache to exist for 'go mod edit'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bryan C. Mills committed Jun 21, 2021
1 parent 460900a commit 117ebe0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/modfetch/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 15 additions & 0 deletions src/cmd/go/testdata/script/mod_edit_no_modcache.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 117ebe0

Please sign in to comment.