In the following code, how can I add proper timeout error handling in case one of the launched go routines takes too long (e.g. > 10 sec) to finish? Note, that I do not want to have an "overall" timeout but a timeout for each go routine, so that I can also know which go routine timed out in my error report.
var wg sync.WaitGroup
for _, element:= range elements{
wg.Add(1)
go doWork(element, &wg)
}
wg.Wait()
kind regards