Golang math/rand.Int() function example

package math/rand

Golang math/rand.Int() function usage example

 package main

 import (
 "fmt"
 "math/rand"
 )

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

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

Reference :

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

Advertisement