package main import ( "log" "time" "github.com/ably/ably-go/ably" ) func main() { opt := &ably.ClientOptions{} opt.Key = "kY92tg.1qo8DQ:CS755GfXwEGtBiIr" a, err := ably.NewRealtimeClient(opt) panicIfErr(err) chn := a.Channels.Get("test") sub, err := chn.Subscribe() panicIfErr(err) for { select { case m := <-sub.MessageChannel(): log.Println("Received:", m.Data) case <-time.After(4 * time.Second): // This will reset each pass log.Println("timeout") } } } func panicIfErr(err error) { if err != nil { panic(err) } }