func()

in get-started-with-redis/pubsub.go [97:113]


func (team *Team) receive(ctx context.Context, resChan chan<- Res) {
	ch := team.channel.Channel()
	defer close(resChan)
	for {
		select {
		case msg, ok := <-ch:
			if !ok {
				// The pubsub channel has been closed
				return
			}
			resChan <- Res{fmt.Sprintf("%s received challenge '%s'", team.name, msg.Payload), nil}
		case <-ctx.Done():
			resChan <- Res{"", ctx.Err()}
			return
		}
	}
}