-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
by nanjunjie:
From document of rand.Intn: Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0. I found it always returns a fixed number sequence. For example on my machine, the sequence for Intn(10) is: :8, 6, 6, 7, 0... What steps will reproduce the problem? Source: package main import ( "fmt" "math/rand" ) func main() { fmt.Println(rand.Intn(10)) } Link: http://play.golang.org/p/1EUY0jaitW What is the expected output? It should return a random number. What do you see instead? On play.golang.org, the output is always 1 for each run. On my machine, the output is always 8. Which operating system are you using? Ubuntu 12.04 Which version are you using? (run 'go version') go version devel +ea15e7ed6d72 Sun Dec 09 03:59:33 2012 -0500 Please provide any additional information below.