content: update balance.go to remove compile errors
Explicitly cast time.Duration values to avoid compile-time errors.
Change-Id: I394c248704023234c6e54bcde696734a35d4b5d0
GitHub-Last-Rev: 252a12f6a028d43ac0139ec99e52b20ca521c5d7
GitHub-Pull-Request: golang/talks#4
Reviewed-on: https://go-review.googlesource.com/c/talks/+/184083
Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/content/2010/io/balance.go b/content/2010/io/balance.go
index 8388cfd..0214750 100644
--- a/content/2010/io/balance.go
+++ b/content/2010/io/balance.go
@@ -22,7 +22,7 @@
// Simulation of some work: just sleep for a while and report how long.
func op() int {
n := rand.Int63n(1e9)
- time.Sleep(nWorker * n)
+ time.Sleep(time.Duration(nWorker * n))
return int(n)
}
@@ -34,7 +34,7 @@
func requester(work chan Request) {
c := make(chan int)
for {
- time.Sleep(rand.Int63n(nWorker * 2e9))
+ time.Sleep(time.Duration(rand.Int63n(nWorker * 2e9)))
work <- Request{op, c}
<-c
}