From 01a5f6de689fa9f0ce0b7acfd35529ad86a07fc7 Mon Sep 17 00:00:00 2001
From: Mark McGranaghan
Date: Fri, 9 Feb 2018 14:14:25 -0800
Subject: [PATCH] Use more idiomatic * for intervals
---
examples/rate-limiting/rate-limiting.go | 4 ++--
examples/rate-limiting/rate-limiting.hash | 4 ++--
examples/select/select.go | 4 ++--
examples/select/select.hash | 4 ++--
examples/tickers/tickers.go | 4 ++--
examples/tickers/tickers.hash | 4 ++--
examples/timeouts/timeouts.go | 8 ++++----
examples/timeouts/timeouts.hash | 4 ++--
examples/timers/timers.go | 2 +-
examples/timers/timers.hash | 4 ++--
public/rate-limiting | 6 +++---
public/select | 6 +++---
public/tickers | 6 +++---
public/timeouts | 10 +++++-----
public/timers | 4 ++--
15 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/examples/rate-limiting/rate-limiting.go b/examples/rate-limiting/rate-limiting.go
index 8a131cb..f5eea19 100644
--- a/examples/rate-limiting/rate-limiting.go
+++ b/examples/rate-limiting/rate-limiting.go
@@ -24,7 +24,7 @@ func main() {
// This `limiter` channel will receive a value
// every 200 milliseconds. This is the regulator in
// our rate limiting scheme.
- limiter := time.Tick(time.Millisecond * 200)
+ limiter := time.Tick(200 * time.Millisecond)
// By blocking on a receive from the `limiter` channel
// before serving each request, we limit ourselves to
@@ -49,7 +49,7 @@ func main() {
// Every 200 milliseconds we'll try to add a new
// value to `burstyLimiter`, up to its limit of 3.
go func() {
- for t := range time.Tick(time.Millisecond * 200) {
+ for t := range time.Tick(200 * time.Millisecond) {
burstyLimiter <- t
}
}()
diff --git a/examples/rate-limiting/rate-limiting.hash b/examples/rate-limiting/rate-limiting.hash
index 81be22f..ccbbc49 100644
--- a/examples/rate-limiting/rate-limiting.hash
+++ b/examples/rate-limiting/rate-limiting.hash
@@ -1,2 +1,2 @@
-b8dbdb8d53386f00ff900fea62db400d962b4834
-h9TUTv494TN
+edad78bf3b36ddc9bec30b344b8a72be4de90f3b
+l4uDE-RCDpa
diff --git a/examples/select/select.go b/examples/select/select.go
index fba2346..cd9e418 100644
--- a/examples/select/select.go
+++ b/examples/select/select.go
@@ -17,11 +17,11 @@ func main() {
// of time, to simulate e.g. blocking RPC operations
// executing in concurrent goroutines.
go func() {
- time.Sleep(time.Second * 1)
+ time.Sleep(1 * time.Second)
c1 <- "one"
}()
go func() {
- time.Sleep(time.Second * 2)
+ time.Sleep(2 * time.Second)
c2 <- "two"
}()
diff --git a/examples/select/select.hash b/examples/select/select.hash
index df807f5..5037668 100644
--- a/examples/select/select.hash
+++ b/examples/select/select.hash
@@ -1,2 +1,2 @@
-72503557ab54ef765eeba153fe8a3446541dfc5f
-Vco7d8Lmhn
+8d743edffd7de6bf7bccdf4437f45672b6adc75e
+ZdSOPe1Gj13
diff --git a/examples/tickers/tickers.go b/examples/tickers/tickers.go
index 4db2759..ef55c97 100644
--- a/examples/tickers/tickers.go
+++ b/examples/tickers/tickers.go
@@ -15,7 +15,7 @@ func main() {
// channel that is sent values. Here we'll use the
// `range` builtin on the channel to iterate over
// the values as they arrive every 500ms.
- ticker := time.NewTicker(time.Millisecond * 500)
+ ticker := time.NewTicker(500 * time.Millisecond)
go func() {
for t := range ticker.C {
fmt.Println("Tick at", t)
@@ -25,7 +25,7 @@ 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 1600ms.
- time.Sleep(time.Millisecond * 1600)
+ time.Sleep(1600 * time.Millisecond)
ticker.Stop()
fmt.Println("Ticker stopped")
}
diff --git a/examples/tickers/tickers.hash b/examples/tickers/tickers.hash
index 02465e8..0404929 100644
--- a/examples/tickers/tickers.hash
+++ b/examples/tickers/tickers.hash
@@ -1,2 +1,2 @@
-5d97b8ebdf36a65f0e92040bae0097f60b79e1ed
-MO3ndiv5qR
+7dc6447323f493f72aa70952bf3e3f2c6156f82f
+Rgc_UDvHv6a
diff --git a/examples/timeouts/timeouts.go b/examples/timeouts/timeouts.go
index 2f545f2..2f110d1 100644
--- a/examples/timeouts/timeouts.go
+++ b/examples/timeouts/timeouts.go
@@ -15,7 +15,7 @@ func main() {
// after 2s.
c1 := make(chan string, 1)
go func() {
- time.Sleep(time.Second * 2)
+ time.Sleep(2 * time.Second)
c1 <- "result 1"
}()
@@ -28,7 +28,7 @@ func main() {
select {
case res := <-c1:
fmt.Println(res)
- case <-time.After(time.Second * 1):
+ case <-time.After(1 * time.Second):
fmt.Println("timeout 1")
}
@@ -36,13 +36,13 @@ func main() {
// from `c2` will succeed and we'll print the result.
c2 := make(chan string, 1)
go func() {
- time.Sleep(time.Second * 2)
+ time.Sleep(2 * time.Second)
c2 <- "result 2"
}()
select {
case res := <-c2:
fmt.Println(res)
- case <-time.After(time.Second * 3):
+ case <-time.After(3 * time.Second):
fmt.Println("timeout 2")
}
}
diff --git a/examples/timeouts/timeouts.hash b/examples/timeouts/timeouts.hash
index ae18eff..64d1c5a 100644
--- a/examples/timeouts/timeouts.hash
+++ b/examples/timeouts/timeouts.hash
@@ -1,2 +1,2 @@
-5ea69771a4d4c6286fd587f91e03cd386f77cada
-NR2GHXUKeM
+93343e1aacb14f818c87732914c29ba57afab245
+MgcfA-xpJO9
diff --git a/examples/timers/timers.go b/examples/timers/timers.go
index 08fe02b..61cbdde 100644
--- a/examples/timers/timers.go
+++ b/examples/timers/timers.go
@@ -15,7 +15,7 @@ func main() {
// tell the timer how long you want to wait, and it
// provides a channel that will be notified at that
// time. This timer will wait 2 seconds.
- timer1 := time.NewTimer(time.Second * 2)
+ timer1 := time.NewTimer(2 * time.Second)
// The `<-timer1.C` blocks on the timer's channel `C`
// until it sends a value indicating that the timer
diff --git a/examples/timers/timers.hash b/examples/timers/timers.hash
index 911fc88..f51b1f0 100644
--- a/examples/timers/timers.hash
+++ b/examples/timers/timers.hash
@@ -1,2 +1,2 @@
-a5b44952d93152ba6bfdb100ea30cd8446cad47e
-6fSHrYxpMu
+e10c601ab3b702dfcea728c1edb31673561484b5
+pybl9hRvJq2
diff --git a/public/rate-limiting b/public/rate-limiting
index f453286..39a49c9 100644
--- a/public/rate-limiting
+++ b/public/rate-limiting
@@ -43,7 +43,7 @@ channels, and tickers.
-
+
@@ -104,7 +104,7 @@ our rate limiting scheme.
|
- limiter := time.Tick(time.Millisecond * 200)
+ limiter := time.Tick(200 * time.Millisecond)
|
@@ -169,7 +169,7 @@ value to burstyLimiter
, up to its limit of 3.
go func() {
- for t := range time.Tick(time.Millisecond * 200) {
+ for t := range time.Tick(200 * time.Millisecond) {
burstyLimiter <- t
}
}()
diff --git a/public/select b/public/select
index 86c2434..6384e8b 100644
--- a/public/select
+++ b/public/select
@@ -41,7 +41,7 @@ select is a powerful feature of Go.
|
-
+
@@ -97,11 +97,11 @@ executing in concurrent goroutines.
|
go func() {
- time.Sleep(time.Second * 1)
+ time.Sleep(1 * time.Second)
c1 <- "one"
}()
go func() {
- time.Sleep(time.Second * 2)
+ time.Sleep(2 * time.Second)
c2 <- "two"
}()
diff --git a/public/tickers b/public/tickers
index 8988089..18d65e0 100644
--- a/public/tickers
+++ b/public/tickers
@@ -43,7 +43,7 @@ periodically until we stop it.
|
-
+
@@ -85,7 +85,7 @@ the values as they arrive every 500ms.
|
- ticker := time.NewTicker(time.Millisecond * 500)
+ ticker := time.NewTicker(500 * time.Millisecond)
go func() {
for t := range ticker.C {
fmt.Println("Tick at", t)
@@ -105,7 +105,7 @@ channel. We’ll stop ours after 1600ms.
|
- time.Sleep(time.Millisecond * 1600)
+ time.Sleep(1600 * time.Millisecond)
ticker.Stop()
fmt.Println("Ticker stopped")
}
diff --git a/public/timeouts b/public/timeouts
index d8f346d..46d44ab 100644
--- a/public/timeouts
+++ b/public/timeouts
@@ -42,7 +42,7 @@ elegant thanks to channels and select .
|
-
+
@@ -85,7 +85,7 @@ after 2s.
c1 := make(chan string, 1)
go func() {
- time.Sleep(time.Second * 2)
+ time.Sleep(2 * time.Second)
c1 <- "result 1"
}()
@@ -108,7 +108,7 @@ if the operation takes more than the allowed 1s.
select {
case res := <-c1:
fmt.Println(res)
- case <-time.After(time.Second * 1):
+ case <-time.After(1 * time.Second):
fmt.Println("timeout 1")
}
@@ -126,13 +126,13 @@ from c2 will succeed and we’ll print the result.
c2 := make(chan string, 1)
go func() {
- time.Sleep(time.Second * 2)
+ time.Sleep(2 * time.Second)
c2 <- "result 2"
}()
select {
case res := <-c2:
fmt.Println(res)
- case <-time.After(time.Second * 3):
+ case <-time.After(3 * time.Second):
fmt.Println("timeout 2")
}
}
diff --git a/public/timers b/public/timers
index e87596b..1b67628 100644
--- a/public/timers
+++ b/public/timers
@@ -43,7 +43,7 @@ at tickers.
|
-
+
@@ -85,7 +85,7 @@ time. This timer will wait 2 seconds.
|
- timer1 := time.NewTimer(time.Second * 2)
+ timer1 := time.NewTimer(2 * time.Second)
|