aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modfetch/fetch.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2019-10-18 16:52:12 -0400
committerBryan C. Mills <bcmills@google.com>2019-10-21 15:48:39 +0000
commit84b0e3665d9684b9957103deaa9c5984c146cdfd (patch)
tree68c1cb13d98c0b40f8dfc5dfe6fde19e92df3c9b /src/cmd/go/internal/modfetch/fetch.go
parentb653c878b1ad8d1b4f8d7b04201d0cb0a4156ead (diff)
downloadgo-84b0e3665d9684b9957103deaa9c5984c146cdfd.tar.gz
go-84b0e3665d9684b9957103deaa9c5984c146cdfd.zip
cmd/go: add a flag to avoid creating unwritable directories in the module cache
This change adds the '-modcacherw' build flag, which leaves newly-created directories (but not the files!) in the module cache read-write instead of making them unwritable. Fixes #31481 Change-Id: I7c21a53dd145676627c3b51096914ce797991d99 Reviewed-on: https://go-review.googlesource.com/c/go/+/202079 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modfetch/fetch.go')
-rw-r--r--src/cmd/go/internal/modfetch/fetch.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cmd/go/internal/modfetch/fetch.go b/src/cmd/go/internal/modfetch/fetch.go
index 8f792a7768..438c6212b5 100644
--- a/src/cmd/go/internal/modfetch/fetch.go
+++ b/src/cmd/go/internal/modfetch/fetch.go
@@ -125,9 +125,11 @@ func download(mod module.Version, dir string) (err error) {
return err
}
- // Make dir read-only only *after* renaming it.
- // os.Rename was observed to fail for read-only directories on macOS.
- makeDirsReadOnly(dir)
+ if !cfg.BuildModcacheRW {
+ // Make dir read-only only *after* renaming it.
+ // os.Rename was observed to fail for read-only directories on macOS.
+ makeDirsReadOnly(dir)
+ }
return nil
}