Context

How to implement timeout in go routines

How to implement timeout in go routines

Go lang simple workers with timeout using context

I wanted to implement a timeout in go routines. There are a couple o ways doing that. We could use context.WithTimeout() or we go with classical sync.WaitGroup group with a trick.

Let’s start with the first one.