I am working on a program with a manager/worker style setup. It has n
number of workers that get data from an http source, push the data onto a gameData channel, pull url information off of a urlData channel and repeat. I then have one goroutine that is supposed to be parsing the data from the api that pulls from the channel gameData and pushes urls onto urlData channel.
My problem is that the second time either goroutine tried to push something onto one of the channels, the goroutines halt and I have to kill the program.
Here is some of the code and a link to the repo: https://github.com/gaigepr/lolTeams
EDIT:
After reading the comments about using buffered channels, the problem is obviously a deadlock. However, making the channels buffered just makes the deadlock take longer to happen.
At this point is synchronizing the parser and getgames threads the way to go to ensure no deadlocks?
EDIT2:
I refactored the program so that now I am using a threadsafe queue to store the summonerID as well as each worker thread now calls the parser function on its own data. This simplified things in a good way. I did this because I was unable to work around the playerChan eventually filling up because of the nature of the data accumulating. unless someone has a reason not to, I will leave this question open to see if someone has an answer that solves to channel problem.