The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

538635 (2) [Avatar] Offline
	// Launch a goroutine to monitor when all the work is done.
	go func() {
		// Wait for everything to be processed.

		// Close the channel to signal to the Display
		// function that we can exit the program.

This is the example code in Listing 2.25, I understand that waitGroup.Wait is waiting all goroutine in group is finished, but why we need to use a new goroutine to call an anonymous function instead of calling waitGroup.Wait() and close(results) just before Display inside Run() method?
538635 (2) [Avatar] Offline
Additional investigation:

It will block the program if I move waitGroup.Wait() and close(results) outside goroutine function. With an unbuffered channel, WaitGroup counter does not count down to zero if it does not Display(read) messages from channel. As the results in channel are not read yet, it blocks at writing result into channel after getting to a size. Once I use a buffered channel with a big number
results := make(chan *Result, 100)
it will no longer block the channel anymore.

So, what is the default unbuffered channel size in this behavior?