Closed yuldashboev closed 1 year ago
Consider the code below causing data racing because of unprotected conversations map
```
chgpt := chatgpt.Init()
go func() {
ch, err := chgpt.SendMessage("test-racing", 123456)
if err != nil {
panic(err)
}
for range ch {
}
}()
go func() {
ch, err := chgpt.SendMessage("test-racing", 123457)
if err != nil {
panic(err)
}
for range ch {
}
}()
Fixed this data racing by protecting map with mutex.
because there is no logic below for loop, we can just return from the function making code clearer.