From 1a10f7c4da33914e9ccb7206c57092b0bbe78fa0 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 25 Jan 2016 10:47:22 +0000 Subject: [PATCH] init rand with time --- common/dice/dice.go | 5 +++++ common/net/testing/port.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common/dice/dice.go b/common/dice/dice.go index 01d2ca80..742d563f 100644 --- a/common/dice/dice.go +++ b/common/dice/dice.go @@ -2,6 +2,7 @@ package dice import ( "math/rand" + "time" ) func Roll(n int) int { @@ -10,3 +11,7 @@ func Roll(n int) int { } return rand.Intn(n) } + +func init() { + rand.Seed(time.Now().Unix()) +} diff --git a/common/net/testing/port.go b/common/net/testing/port.go index b49d60a7..465f86db 100644 --- a/common/net/testing/port.go +++ b/common/net/testing/port.go @@ -6,5 +6,5 @@ import ( ) func PickPort() v2net.Port { - return v2net.Port(30000 + dice.Roll(10000)) + return v2net.Port(30000 + dice.Roll(5000)) }