The WaitGroup works if wg.Add() is called within the goroutine. The only purpose for the WaitGroup is to keep main from exiting before the goroutine has completed.
Moving wg.Add() outside of the goroutine has no effect if the channel is unbuffered. But if I make the channel buffered and move the wg.Add() outside the goroutine then the code runs in a loop printing 0 and never stops. This is another behavior that I don't understand.
Why does making disconnectCh buffered cause the goroutine to never run, or to run in a loop printing 0?