Golang math/rand.New() function example
package math/rand
Golang math/rand.New() function usage example
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
n := 10
i := 0
r := rand.New(rand.NewSource(time.Now().UnixNano())) //<--- here
for i < n {
x := r.Uint32()
fmt.Println(x)
i += 1
}
}
Reference :
Advertisement
Something interesting
Tutorials
+11.6k Golang : Convert(cast) float to int
+17.4k Golang : Get future or past hours, minutes or seconds
+48.1k Golang : How to convert JSON string to map and slice
+4.5k Java : Generate multiplication table example
+7.1k Golang : Get Alexa ranking data example
+20k Golang : How to run your code only once with sync.Once object
+7k Golang : Takes a plural word and makes it singular
+22.1k Golang : Repeat a character by multiple of x factor
+6.8k Golang : Calculate pivot points for a cross
+28.5k Golang : Change a file last modified date and time
+20.2k Golang : Determine if directory is empty with os.File.Readdir() function