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
+21.2k Golang : Clean up null characters from input data
+19.6k Golang : Set or Add HTTP Request Headers
+5.4k Golang : What is StructTag and how to get StructTag's value?
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+8.4k Golang : Ackermann function example
+37.7k Golang : Comparing date or timestamp
+5.9k Unix/Linux : How to open tar.gz file ?
+10.5k Swift : Convert (cast) String to Integer
+4.5k Java : Generate multiplication table example
+12.5k Golang : HTTP response JSON encoded data
+40.1k Golang : UDP client server read write example