The closure in the group.work() function in group.go has a race hazard sending to the channel inside the closure.
Link to code
For loops reuse the variables defined in their scope, meaning that the data available to a closure evoked in a go routine is not thread-safe.
Eg:
for ch, _ := range g.members {
go func()
// ch not safe to use here
}()
}
Either taking a copy of the variable or passing it to the function as an argument would fix this errror.
The closure in the
group.work()function ingroup.gohas a race hazard sending to the channel inside the closure.Link to code
For loops reuse the variables defined in their scope, meaning that the data available to a closure evoked in a go routine is not thread-safe.
Eg:
Either taking a copy of the variable or passing it to the function as an argument would fix this errror.