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

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

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

I linked a go playground version that is properly formatted

Use the data race detector of go.

go run -race main.go

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.

1 Like