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
+14.8k Golang : Find commonalities in two slices or arrays example
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+28k Golang : Move file to another directory
+18.8k Golang : Implement getters and setters
+7.5k Golang : Rot13 and Rot5 algorithms example
+48.1k Golang : How to convert JSON string to map and slice
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+6.3k Golang : Extract sub-strings
+6k Linux/MacOSX : Search for files by filename and extension with find command
+9.5k Golang : Get all countries currencies code in JSON format
+10.2k Golang : How to profile or log time spend on execution?
+13.9k Golang : Get dimension(width and height) of image file