]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modload: respect overlays when loading go.work files
authorMichael Matloob <matloob@golang.org>
Mon, 3 Jun 2024 22:42:12 +0000 (18:42 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 6 Jun 2024 18:35:34 +0000 (18:35 +0000)
commit2be4b3913a3693958f95b520a309bfc4fda0ee21
tree9a7cf8746093897b0856c9a3a9a12b66127f3c30
parent1831437f197d43608c8086dc42530a89d975aba2
cmd/go/internal/modload: respect overlays when loading go.work files

Before this change, we didn't initialize the overlays in the fsys
package or use the fsys logic to read the files, so overlays were not
respected for go.work files. Initialize fsys before loading the go.work
file (initialization is idempotent) and use the new fsys.ReadFile
function to read the file instead of os.ReadFile.

fsys.ReadFile just opens the file with fsys.Open and then calls
io.ReadAll on it. (This is less efficient than what os.ReadFile does:
os.ReadFile reads into a buffer it allocated that's the file's size
while io.ReadAll doesn't know how big the file is so it just reads in
512 byte chunks.)

Change-Id: Ic40bcbb483a16c5d4dd1d896306ea99a16f370f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/590755
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/fsys/fsys.go
src/cmd/go/internal/modload/init.go
src/cmd/go/testdata/script/work_overlay.txt [new file with mode: 0644]