Golang math/rand.Int31n() function example
package math/rand
Golang math/rand.Int31n() function usage example
package main
import (
"fmt"
"math/rand"
)
func main() {
n := 10
i := 0
var x int32
for i < n {
x = rand.Int31n(10)
fmt.Println("x : ", x)
i += 1
}
fmt.Println("i : ", i)
}
Reference :
Advertisement
Something interesting
Tutorials
+14k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+8.8k Golang : Random integer with rand.Seed() within a given range
+7.3k Golang : Of hash table and hash map
+4.9k HTTP common errors and their meaning explained
+4.6k JavaScript : Rounding number to decimal formats to display currency
+21.3k Golang : Create and resolve(read) symbolic links
+14k Golang : Compress and decompress file with compress/flate example
+5.6k Javascript : How to refresh page with JQuery ?
+6.7k Golang : Skip or discard items of non-interest when iterating example
+18k Golang : Get all upper case or lower case characters from string example
+5.8k Unix/Linux : Get reboot history or check when was the last reboot date
+51.9k Golang : How to get time in milliseconds?