Race detect!!!
WARNING: DATA RACE Read at 0x00c0000601f0 by goroutine 39: runtime.chansend() d:/coding/golang/src/runtime/chan.go:142 +0x0
d:/coding/golang/_home/src/github.com/jeffallen/mqtt/mqtt.go:885 +0x23d
Previous write at 0x00c0000601f0 by goroutine 43: runtime.closechan() d:/coding/golang/src/runtime/chan.go:334 +0x0 github.com/jeffallen/mqtt.(*ClientConn).reader.func1() d:/coding/golang/_home/src/github.com/jeffallen/mqtt/mqtt.go:743 +0x5b github.com/jeffallen/mqtt.(*ClientConn).reader() d:/coding/golang/_home/src/github.com/jeffallen/mqtt/mqtt.go:754 +0x630
I gave this a quick look, and I'm not in a position to solve this soon. If you have a suggested fix for it, send a PR and I'll take a look at it.
The easiest solution is to introduce mutexes. Unfortunately, I do not have time to make my code correct. The authorities do not want to hear anything, but there is definitely a problem.