Skip to content

Instantly share code, notes, and snippets.

@altn980
Created December 27, 2017 15:14
Show Gist options
  • Save altn980/aab1fd7a532e81a02d72fe16d67592bd to your computer and use it in GitHub Desktop.
Save altn980/aab1fd7a532e81a02d72fe16d67592bd to your computer and use it in GitHub Desktop.
golangでbitflyerのpubnubを使う簡易サンプル
package main
import (
"github.com/pubnub/go/messaging"
"fmt"
)
func main() {
pubnub := messaging.NewPubnub(
"", "sub-c-52a9ab50-291b-11e5-baaa-0619f8945a4f",
"", "", false, "", nil)
channel := "lightning_board_FX_BTC_JPY"
sucCha := make(chan []byte)
errCha := make(chan []byte)
go pubnub.Subscribe(channel, "", sucCha, false, errCha)
for {
select {
case res := <-sucCha:
fmt.Println(string(res))
case err := <-errCha:
fmt.Println(string(err))
case <-messaging.SubscribeTimeout():
fmt.Println("Subscribe() timeout")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment