After I updated my Linux machine to kernel 4.1x, my program suddenly stopped working or precisely speaking, not working until 1 minute later. Once it runs, it runs smoothly afterward.

After spending hours of trial and error, I finally figured out that it is related to the package crypto/rand. Once you read from the rand.Reader, it stuck.

Analysis

There are actually two random number generators (RNG) in golang: math/rand and crypto/rand. The key difference between the two is that the former one is a pseudo-RNG (PRNG) and the latter one is a true RNG (and slower).

As a real RNG, it reads directly from /dev/urandom on Linux, and it only can be done when Linux had collected enough entropy which is usually insufficient on startup. The official way to do it is to wait until enough entropy is collected, and it typically costs about 1 minute.

There is a discussion about the entropy problem in github:
https://github.com/golang/go/issues/22614

Solution