Golang math/rand.Int31() function example

package math/rand

Golang math/rand.Int31() function usage example

 package main

 import (
 "fmt"
 "math/rand"
 )

 func main() {
 n := 10
 i := 0
 var x int32

 for i < n {
 x = rand.Int31()
 i += 1
 }
 fmt.Println("x : ", x)
 fmt.Println("i : ", i)
 }

Reference :

http://golang.org/pkg/math/rand/#Int31

Advertisement