Original post

I was testing one of my mocks, during race tests I got this error:

panic: Log in goroutine after TestMock_Start has completed 

I was using a select statement to make the goroutine exit from the send operation, meaning that if the instance was shutdown then the goroutine would not stay there hanging:

// SendMockData injects mock data func (s *Mock) SendMockData(data interface{}) {  func() { select { case <-s.shutdown: s.test.Log("exit before data was received") case s.data <- data: } }() } 

The offending line is of the s.test.Log; since the race detector is complaining about this I am wondering if using a shutdown channel to stop send operations is good practice or not.

submitted by /u/ismokewaytoomanycigs
[link] [comments]