This repository was archived by the owner on Apr 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 11language : go
22
33go :
4- - 1.3
5- - 1.4
6- - 1.5
7- - 1.6
8- - 1.7
9- - 1.8
10- - 1.9
4+ - " 1.3"
5+ - " 1.4"
6+ - " 1.5"
7+ - " 1.6"
8+ - " 1.7"
9+ - " 1.8"
10+ - " 1.9"
11+ - " 1.10"
12+ - " 1.11"
13+ - " 1.12"
1114
1215script :
1316 - ./validate.sh
Original file line number Diff line number Diff line change @@ -219,9 +219,9 @@ type metricKV struct {
219219}
220220
221221func (r * StandardRegistry ) registered () []metricKV {
222- metrics := make ([]metricKV , 0 , len (r .metrics ))
223222 r .mutex .RLock ()
224223 defer r .mutex .RUnlock ()
224+ metrics := make ([]metricKV , 0 , len (r .metrics ))
225225 for name , i := range r .metrics {
226226 metrics = append (metrics , metricKV {
227227 name : name ,
Original file line number Diff line number Diff line change @@ -377,3 +377,17 @@ func TestConcurrentRegistryAccess(t *testing.T) {
377377 t .Fatal (i )
378378 }
379379}
380+
381+ // exercise race detector
382+ func TestRegisterAndRegisteredConcurrency (t * testing.T ) {
383+ r := NewRegistry ()
384+ wg := & sync.WaitGroup {}
385+ wg .Add (1 )
386+ go func (r Registry , wg * sync.WaitGroup ) {
387+ defer wg .Done ()
388+ r .Each (func (name string , iface interface {}) {
389+ })
390+ }(r , wg )
391+ r .Register ("foo" , NewCounter ())
392+ wg .Wait ()
393+ }
You can’t perform that action at this time.
0 commit comments