aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRoy Reznik <roy@wiz.io>2025-06-22 12:37:23 +0000
committerMichael Matloob <matloob@google.com>2025-08-01 11:56:27 -0700
commit4ab1aec00799f91e96182cbbffd1de405cd52e93 (patch)
tree2e462040f787589b04d4a771545e0c540fa3fdb2 /src/cmd
parente666972a674eb96f5847c7bbeb5c6e1bcb572af5 (diff)
downloadgo-4ab1aec00799f91e96182cbbffd1de405cd52e93.tar.xz
cmd/go: modload should use a read-write lock to improve concurrency
This PR will be imported into Gerrit with the title and first comment (this text) used to generate the subject and body of the Gerrit change. Change-Id: I3f9bc8a2459059a924a04fa02794e258957819b5 GitHub-Last-Rev: 6ad6f6a70e21dc45fc0c880b8732fb87c656c520 GitHub-Pull-Request: golang/go#74311 Reviewed-on: https://go-review.googlesource.com/c/go/+/683215 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Ian Alexander <jitsu@google.com> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/go/internal/modload/init.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go
index e537fddfcd..cb9d74df68 100644
--- a/src/cmd/go/internal/modload/init.go
+++ b/src/cmd/go/internal/modload/init.go
@@ -149,7 +149,7 @@ type MainModuleSet struct {
// highest replaced version of each module path; empty string for wildcard-only replacements
highestReplaced map[string]string
- indexMu sync.Mutex
+ indexMu sync.RWMutex
indices map[module.Version]*modFileIndex
}
@@ -228,8 +228,8 @@ func (mms *MainModuleSet) GetSingleIndexOrNil() *modFileIndex {
}
func (mms *MainModuleSet) Index(m module.Version) *modFileIndex {
- mms.indexMu.Lock()
- defer mms.indexMu.Unlock()
+ mms.indexMu.RLock()
+ defer mms.indexMu.RUnlock()
return mms.indices[m]
}