Last active
February 26, 2018 15:13
-
-
Save syossan27/d88ae320162bd2d7b736958cae903f29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| func main() { | |
| // シグナルを受け取るまで待ち受けるためのChannel | |
| doneCh := make(chan struct{} | |
| t := tebata.New(syscall.SIGINT, syscall.SIGTERM) | |
| t.Reserve(func(doneCh chan struct{}){ | |
| doneCh <- struct{}{} | |
| }, doneCh) | |
| // メッセージを受け取る処理をgoroutineで動かす | |
| go receive() | |
| // シグナルを受け取るまで待ち受ける | |
| <-doneCh | |
| } | |
| func receive() { | |
| for { | |
| select { | |
| // case msg := <-hoge(): メッセージを受け取って何か処理を行なう | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment