select {
case mark:= <- ch:
//
handlePrice(mark)
ticker.Reset(time.Minute)
case <-ticker.C:
// ticker triggered, the websocket may be broken, try reconnect
cli.Cancel()
cli = ws.NewClient()
// resubscribe
cli.Public.MarkPrice(req, ch)
}
}
**Expected behavior**
no panic
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- Device: [e.g Macbook Pro]
- OS: [e.g. MacOS]
- Version [e.g. 14.1]
happened in macos and ubuntu
**Golang (please complete the following information):**
- Version: 1.17
**Additional context**
Add any other context about the problem here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug
fatal error: concurrent map read and map write
goroutine 28 [running]: runtime.throw({0x75b602, 0x6edb80}) /usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc00015ae10 sp=0xc00015ade0 pc=0x434991 runtime.mapaccess1(0x6fee40, 0xc000179170, 0xa3a700) /usr/local/go/src/runtime/map.go:411 +0x1f7 fp=0xc00015ae50 sp=0xc00015ae10 pc=0x40f737 github.com/amir-the-h/okex/api/ws.(ClientWs).sender(0xc00032c000, 0x0) /go/pkg/mod/github.com/amir-the-h/okex@v1.1.4-alpha/api/ws/client.go:282 +0x212 fp=0xc00015af88 sp=0xc00015ae50 pc=0x6bf992 github.com/amir-the-h/okex/api/ws.(ClientWs).dial.func2() /go/pkg/mod/github.com/amir-the-h/okex@v1.1.4-alpha/api/ws/client.go:245 +0x25 fp=0xc00015afe0 sp=0xc00015af88 pc=0x6bf645 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00015afe8 sp=0xc00015afe0 pc=0x463ee1 created by github.com/amir-the-h/okex/api/ws.(*ClientWs).dial /go/pkg/mod/github.com/amir-the-h/okex@v1.1.4-alpha/api/ws/client.go:244 +0x29f
To Reproduce
cli := ws.NewClient() ch := make(chan *pub.MarkPrice) // subscribe mark price channel cli.Public.MarkPrice(req, ch)
for {