import ( "math/rand" "time")// ...rand.Seed(time.Now().Unix() // initialize global pseudo random generatormessage := fmt.Sprint("Gonna work from home...",reasons[rand.Intn(len(reasons))]) ) g5 k6 U$ y3 F! K0 n' M5 R
使用其他解决方案Rand对象。 ' z0 W) D8 Q5 e* p
s := rand.NewSource(time.Now().Unix())r := rand.New(s) // initialize local pseudorandom generator r.Intn(len(reasons)); h8 Y) A) F4 p3 H+ r1 c/ ?' E; e