I need to write large amount of data to text file from a number of goroutines (say 30) concurrently. What I do is this:
workers.Add(core.Concurrency)
for i := 0; i < core.Concurrency; i++ {
go func() {
defer workers.Done()
writer := bufio.NewWriter(f)
defer writer.Flush()
a.Worker(workChan, writer)
}()
}
But this doesn't seems to work for some cases. Here f
is the *os.File
object. This doesn't writes to the file in some cases at all, and in some cases it writes some data but doesn't do future writes. The behaviour is very inconsistent and there are no errors too.
Any ideas why this might be happening?