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
+7.3k Golang : Of hash table and hash map
+47.8k Golang : Convert int to byte array([]byte)
+7.9k Golang Hello World Example
+10k Golang : Get escape characters \u form from unicode characters
+12.1k Golang : Sort and reverse sort a slice of runes
+8.6k Golang : Progress bar with ∎ character
+18.4k Golang : Read binary file into memory
+11.7k Golang : Secure file deletion with wipe example
+7.4k Golang : Scanf function weird error in Windows
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+7.3k Golang : Not able to grep log.Println() output
+17k Golang : Get input from keyboard