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
+8.9k Golang : Gaussian blur on image and camera video feed examples
+5.7k Fix yum-complete-transaction error
+16.9k Golang : Set up source IP address before making HTTP request
+10.5k Swift : Convert (cast) String to Integer
+8.1k Golang : Variadic function arguments sanity check example
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+31.6k Golang : Get local IP and MAC address
+6.3k Golang : How to get capacity of a slice or array?
+8k Findstr command the Grep equivalent for Windows
+19.2k Golang : Check whether a network interface is up on your machine
+6.1k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+16k Golang : How to reverse elements order in map ?