Golang math/rand.Intn() function example
package math/rand
Golang math/rand.Intn() function usage example
package main
import (
"fmt"
"math/rand"
)
func main() {
n := 10
i := 0
for i < n {
x := rand.Intn(10)
fmt.Println(i, x)
i += 1
}
fmt.Println("i : ", i)
}
Reference :
Advertisement
Something interesting
Tutorials
+6.9k Mac/Linux/Windows : Get CPU information from command line
+24k Golang : Call function from another package
+9.5k Golang : Convert(cast) string to int64
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+11.1k Golang : Web routing/multiplex example
+19.8k Golang : Append content to a file
+7k Golang : Find the shortest line of text example
+21.8k Golang : Convert string slice to struct and access with reflect example
+7.4k Golang : Convert source code to assembly language
+6.8k Golang : Get expvar(export variables) to work with multiplexer
+9.4k Golang : Find the length of big.Int variable example
+10.6k Golang : Flip coin example