I keep getting deadlock error, I'm new to Golang


(Ronald Rajan) #1

https://play.golang.org/p/U7UPrh8LDHH


(Ronald Rajan) #2

I’m trying to take patient data out of a csv file and then parse it to find out which lines of the file have incomplete patient data. This is my first time using Golang so I do not fully understand the language. If I need to be closing the channel please let me know how. Thank you for the help


(catacombs) #3

Please format your code.


(Ronald Rajan) #4

I linked a go playground version that is properly formatted


(Yamil Bracho) #5

Use the data race detector of go.

go run -race main.go


( Kvaz1r) #6

Your channel is an unbuffered so your goroutine will be locked while someone don’t get message from it. So just start function consume in separate routine:

 		go consume(whichones, counter)

and send message after that:

msgs <- record[value]

but, you can’t get more messages than you sent so remove cycle from consume function at all.