Golang math/rand.Int63n() function example

package math/rand

Golang math/rand.Int63n() function usage example

 package main

 import (
  "fmt"
  "math/rand"
 )

 func main() {
  n := 10
  i := 0
  for i < n {
 x := rand.Int63n(10)
 fmt.Println(i, x)
 i += 1
  }

  fmt.Println("i : ", i)
 }

Reference :

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

Advertisement