From a4d9d2f5db4d30ef583afc56b035b3a84393d42c Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Sat, 29 Aug 2015 17:12:27 -0700 Subject: [PATCH 1/3] Use 1600ms to avoid racing --- examples/tickers/tickers.go | 4 ++-- examples/tickers/tickers.hash | 4 ++-- public/tickers | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) 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/tickers b/public/tickers index 849bb50..efb57e0 100644 --- a/public/tickers +++ b/public/tickers @@ -43,7 +43,7 @@ periodically until we stop it.

- +
package main
 
@@ -100,12 +100,12 @@ the values as they arrive every 500ms.

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")
 }

From 7dde60ce9707cd1cff1c238c0b187d5cebb77fd7 Mon Sep 17 00:00:00 2001
From: Jim Walker 
Date: Fri, 4 Sep 2015 17:14:55 -0400
Subject: [PATCH 2/3] Fix typo on random numbers example

---
 examples/random-numbers/random-numbers.go | 4 ++++
 examples/random-numbers/random-numbers.sh | 1 +
 2 files changed, 5 insertions(+)

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.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
 

From 93e2f08a6bfe38c1d0beb052437ee9bf0519ce4a Mon Sep 17 00:00:00 2001
From: Mark McGranaghan 
Date: Sat, 5 Sep 2015 10:19:48 -0700
Subject: [PATCH 3/3] Rebuild

---
 examples/random-numbers/random-numbers.hash | 4 ++--
 public/random-numbers                       | 9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

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/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
 
@@ -124,7 +124,7 @@ other ranges, for example 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.

@@ -167,6 +167,10 @@ produces the same sequence of random numbers.

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)) }
@@ -187,6 +191,7 @@ produces the same sequence of random numbers.

81,87 0.6645600532184904 7.123187485356329,8.434115364335547 +0,28 5,87 5,87