title: how to close dynamic chan in GO
body: <p>Sorry, I can't come up with more explaining thread title.</p>
  
  <p>I'm new at GO and I started from rewriting my app from python to GO because I need pure threads.
  Idea: I've queue where I'm put some initial objects with method X. While iterating this queue I'm calling this method X for each object in it. This method X returns more objects with method X between zero and Y, where Y is unknown. This method X should be threaded and loop should sleep while there's no objects, until all goroutines finishes and no more objects in queue.
  I did initial code, it's working almost as expected, but I dont realize how to check goroutines finished and queue is empty. First try was waitgroup, but it's don't have methods like IsEmpty or Count cause it's threadsafe. Can anyone recommend me any techniques for my problem?</p>
  
  <p>Here is the code <a href="https://play.golang.org/p/-t7hszVmnG" rel="nofollow">https://play.golang.org/p/-t7hszVmnG</a> if you need not cached result add some number for UnixNano in line 50.</p>
  
  <p>Thanks in advance!</p>