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.5k Golang : Handle API query by curl with Gorilla Queries example
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+27.5k Golang : dial tcp: too many colons in address
+4.4k Linux/MacOSX : Search and delete files by extension
+11.6k Golang : Concurrency and goroutine example
+48.5k Golang : Upload file from web browser to server
+9.7k Golang : Detect number of active displays and the display's resolution
+17.6k Golang : delete and modify XML file content
+10.2k Golang : How to profile or log time spend on execution?
+8.8k Golang : Get final balance from bit coin address example
+20.8k Golang : Convert date string to variants of time.Time type examples