-
Notifications
You must be signed in to change notification settings - Fork 511
Closed
Description
I noticed a strange work with channels in the file bot.go
func (b *Bot) Start() {
...
stopPoller := make(chan struct{})
go b.Poller.Poll(b, b.Updates, stopPoller)
for {
select {
case upd := <-b.Updates:
b.incomingUpdate(&upd)
case <-b.stop:
stopPoller <- struct{}{} // why not close?
case <-stopPoller: // read from same channel
return
}
}
}And how this channel uses in long poller:
func (p *LongPoller) Poll(b *Bot, dest chan Update, stop chan struct{}) {
go func(stop chan struct{}) {
<-stop // read again
close(stop) // and close???
}(stop)
...
}stek29