Golang math/rand.NewSource() function example
package math/rand
Golang math/rand.NewSource() 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
+10k Golang : Channels and buffered channels examples
+14k Golang : Google Drive API upload and rename example
+15.2k Golang : How to check if IP address is in range
+13.6k Golang : Set image canvas or background to transparent
+6.4k PHP : Proper way to get UTF-8 character or string length
+8.8k Android Studio : Image button and button example
+6.9k Golang : How to setup a disk space used monitoring service with Telegram bot
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+7.8k Swift : Convert (cast) String to Double
+5.8k Golang : Markov chains to predict probability of next state example
+11.6k Golang : Simple file scaning and remove virus example
+8.9k Golang : Sort lines of text example