Skip to content

Instantly share code, notes, and snippets.

@syossan27
Last active February 26, 2018 15:13
Show Gist options
  • Select an option

  • Save syossan27/d88ae320162bd2d7b736958cae903f29 to your computer and use it in GitHub Desktop.

Select an option

Save syossan27/d88ae320162bd2d7b736958cae903f29 to your computer and use it in GitHub Desktop.
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