summaryrefslogtreecommitdiff
path: root/test/sieve.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-09-04 10:36:13 +1000
committerRob Pike <r@golang.org>2010-09-04 10:36:13 +1000
commit7c2e17b3e6e4c36a3713e272653dcfc9c2056cfd (patch)
treeb5e309f8922e2f29902d7e085ad3943bb480b856 /test/sieve.go
parent83798de970b62e4a4e7b72b9ef53a5d66f71dc3c (diff)
downloadgo-7c2e17b3e6e4c36a3713e272653dcfc9c2056cfd.tar.gz
test: remove semiocolons.
The ken directory is untouched so we have some examples with explicit semis. R=gri CC=golang-dev http://codereview.appspot.com/2157041
Diffstat (limited to 'test/sieve.go')
-rw-r--r--test/sieve.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/sieve.go b/test/sieve.go
index ec2ce446e..4fa111582 100644
--- a/test/sieve.go
+++ b/test/sieve.go
@@ -9,7 +9,7 @@ package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
for i := 2; ; i++ {
- ch <- i // Send 'i' to channel 'ch'.
+ ch <- i // Send 'i' to channel 'ch'.
}
}
@@ -17,22 +17,22 @@ func Generate(ch chan<- int) {
// removing those divisible by 'prime'.
func Filter(in <-chan int, out chan<- int, prime int) {
for {
- i := <-in; // Receive value of new variable 'i' from 'in'.
- if i % prime != 0 {
- out <- i // Send 'i' to channel 'out'.
+ i := <-in // Receive value of new variable 'i' from 'in'.
+ if i%prime != 0 {
+ out <- i // Send 'i' to channel 'out'.
}
}
}
// The prime sieve: Daisy-chain Filter processes together.
func Sieve() {
- ch := make(chan int); // Create a new channel.
- go Generate(ch); // Start Generate() as a subprocess.
+ ch := make(chan int) // Create a new channel.
+ go Generate(ch) // Start Generate() as a subprocess.
for {
- prime := <-ch;
- print(prime, "\n");
- ch1 := make(chan int);
- go Filter(ch, ch1, prime);
+ prime := <-ch
+ print(prime, "\n")
+ ch1 := make(chan int)
+ go Filter(ch, ch1, prime)
ch = ch1
}
}