Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My rand.Intn() was always returning the same value. Seem like you have to to seed it manually (once, in main() for example): rand.Seed( time.Now().UTC().UnixNano())

http://stackoverflow.com/questions/12321133/golang-random-nu...

Edit: It's in the documentation, but you have to look for it.

"Seed uses the provided seed value to initialize the generator to a deterministic state. If Seed is not called, the generator behaves as if seeded by Seed(1)"



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: