- rand
- Float64
- Int
- Intn
Random
- Pseudo Random
- rand
- Go will always start from the same random seed of 1 meaning that this script will always generate the same "random" numbers.
examples/random/random.go
package main import ( "fmt" "math/rand" ) func main() { x := rand.Float64() fmt.Println(x) y := rand.Int() fmt.Println(y) a := rand.Intn(10) // between [0, n) fmt.Println(a) b := rand.Intn(10) // between [0, n) fmt.Println(b) }
0.6046602879796196 8674665223082153551 7 9