Created
December 27, 2017 15:14
-
-
Save altn980/aab1fd7a532e81a02d72fe16d67592bd to your computer and use it in GitHub Desktop.
golangでbitflyerのpubnubを使う簡易サンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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