[Dev] GO言語で一定時間内に終わらなければ処理を中断したい

in #japanese2 days ago

こんにちは、@yasuです。

N秒おきに <-ticker.C が発生する。

ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()

N秒後に <-ctx.Done() が発生する。全 goroutine を終了させる

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

image.png

image.png

Sort:  

Thank you for participating in Steem Bingo by @xpilar! 🎉

You purchased 10 tickets in Round #252 and received a 90% upvote on this post.
To view your round results, click here.

With every ticket purchase, players receive an upvote that is worth more than the cost of the Bingo cards.
For more information, please read the full update here.

Steem Bingo is brought to you by @xpilar and developed by @blaze.apps.




Want to receive your post rewards fully in liquid STEEM?

Use UPEX Liquid Rewards Read more here.