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
+5.3k Javascript : Shuffle or randomize array example
+26.8k Golang : Convert file content into array of bytes
+6.9k Golang : How to solve "too many .rsrc sections" error?
+6.2k Golang : Extract XML attribute data with attr field tag example
+32.4k Golang : Math pow(the power of x^y) example
+19.6k Golang : Set or Add HTTP Request Headers
+9.3k Golang : Generate EAN barcode
+15.2k Golang : Get HTTP protocol version example
+29.2k Golang : missing Git command
+6.1k nginx : force all pages to be SSL
+12.6k Golang : Exit, terminating or aborting a program
+9k Golang : How to use Gorilla webtoolkit context package properly