github.com/RevenueMonster/sqlike@v1.0.6/examples/race.go (about) 1 package examples 2 3 import ( 4 "context" 5 "reflect" 6 "sync" 7 "testing" 8 9 "github.com/RevenueMonster/sqlike/sql/codec" 10 ) 11 12 func testRace(ctx context.Context, t *testing.T) { 13 registry := codec.DefaultRegistry 14 wg := new(sync.WaitGroup) 15 wg.Add(3) 16 getStruct := func(v interface{}) { 17 defer wg.Done() 18 to := reflect.TypeOf(v) 19 if _, err := registry.LookupDecoder(to); err != nil { 20 panic(err) 21 } 22 } 23 go getStruct(struct { 24 Name string 25 Age int 26 }{}) 27 go getStruct(struct { 28 Name string 29 Age int 30 }{}) 31 go getStruct(struct { 32 Name string 33 Age int 34 }{}) 35 wg.Wait() 36 }