Skip to content

Commit 6ad6f6a

Browse files
committed
cmd/go: modload should use a read-write lock to improve concurrency
1 parent 8552bcf commit 6ad6f6a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cmd/go/internal/modload/init.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type MainModuleSet struct {
149149
// highest replaced version of each module path; empty string for wildcard-only replacements
150150
highestReplaced map[string]string
151151

152-
indexMu sync.Mutex
152+
indexMu sync.RWMutex
153153
indices map[module.Version]*modFileIndex
154154
}
155155

@@ -228,8 +228,8 @@ func (mms *MainModuleSet) GetSingleIndexOrNil() *modFileIndex {
228228
}
229229

230230
func (mms *MainModuleSet) Index(m module.Version) *modFileIndex {
231-
mms.indexMu.Lock()
232-
defer mms.indexMu.Unlock()
231+
mms.indexMu.RLock()
232+
defer mms.indexMu.RUnlock()
233233
return mms.indices[m]
234234
}
235235

0 commit comments

Comments
 (0)