diff --git a/examples/random-numbers/random-numbers.go b/examples/random-numbers/random-numbers.go index f46c27a..34b065c 100644 --- a/examples/random-numbers/random-numbers.go +++ b/examples/random-numbers/random-numbers.go @@ -47,4 +47,8 @@ func main() { fmt.Print(r2.Intn(100), ",") fmt.Print(r2.Intn(100)) fmt.Println() + s3 := rand.NewSource(42) + r3 := rand.New(s3) + fmt.Print(r3.Intn(100), ",") + fmt.Print(r3.Intn(100)) } diff --git a/examples/random-numbers/random-numbers.hash b/examples/random-numbers/random-numbers.hash index e68f800..fa0ec46 100644 --- a/examples/random-numbers/random-numbers.hash +++ b/examples/random-numbers/random-numbers.hash @@ -1,2 +1,2 @@ -6ce1f98d3c22ee8bf02c41b393361d6cd5fff23a -TZElZIwNU1 +8e97de760147b061dd09939db294c892211b6b80 +ZdFpbahgC1 diff --git a/examples/random-numbers/random-numbers.sh b/examples/random-numbers/random-numbers.sh index 2f9521e..67c37a8 100644 --- a/examples/random-numbers/random-numbers.sh +++ b/examples/random-numbers/random-numbers.sh @@ -2,6 +2,7 @@ $ go run random-numbers.go 81,87 0.6645600532184904 7.123187485356329,8.434115364335547 +0,28 5,87 5,87 diff --git a/examples/tickers/tickers.go b/examples/tickers/tickers.go index 0d8cbd2..4db2759 100644 --- a/examples/tickers/tickers.go +++ b/examples/tickers/tickers.go @@ -24,8 +24,8 @@ func main() { // Tickers can be stopped like timers. Once a ticker // is stopped it won't receive any more values on its - // channel. We'll stop ours after 1500ms. - time.Sleep(time.Millisecond * 1500) + // channel. We'll stop ours after 1600ms. + time.Sleep(time.Millisecond * 1600) ticker.Stop() fmt.Println("Ticker stopped") } diff --git a/examples/tickers/tickers.hash b/examples/tickers/tickers.hash index d0a1b54..02465e8 100644 --- a/examples/tickers/tickers.hash +++ b/examples/tickers/tickers.hash @@ -1,2 +1,2 @@ -39781500e9ccbd39282e2dce5cb8003715bfe78a -U0PO7ZZU3l +5d97b8ebdf36a65f0e92040bae0097f60b79e1ed +MO3ndiv5qR diff --git a/public/random-numbers b/public/random-numbers index 1221235..33ea2cf 100644 --- a/public/random-numbers +++ b/public/random-numbers @@ -41,7 +41,7 @@ generation.
package main
5.0 <= f' < 10.0
.
The default number generator is deterministic, so it’ll
produce the same sequence of numbers each time by default.
-To make it non-deterministic, give it a seed that changes.
+To produce varying sequences, give it a seed that changes.
Note that this is not safe to use for random numbers you
intend to be secret, use crypto/rand
for those.
package main
Tickers can be stopped like timers. Once a ticker is stopped it won’t receive any more values on its -channel. We’ll stop ours after 1500ms.
+channel. We’ll stop ours after 1600ms. time.Sleep(time.Millisecond * 1500)
+ time.Sleep(time.Millisecond * 1600)
ticker.Stop()
fmt.Println("Ticker stopped")
}