race: Fix detected test race in the internal audit code (#19865)

This commit is contained in:
Anis Eleuch 2024-06-03 16:44:50 +01:00 committed by GitHub
parent a8554c4022
commit 3ba857dfa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,16 +45,14 @@ type Target interface {
type targetsList struct { type targetsList struct {
list []Target list []Target
mu *sync.RWMutex mu sync.RWMutex
} }
func newTargetsList() *targetsList { func newTargetsList() *targetsList {
return &targetsList{ return &targetsList{}
mu: &sync.RWMutex{},
}
} }
func (tl targetsList) get() []Target { func (tl *targetsList) get() []Target {
tl.mu.RLock() tl.mu.RLock()
defer tl.mu.RUnlock() defer tl.mu.RUnlock()