aboutsummaryrefslogtreecommitdiff
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
commit4f61fc96b2788be7cbfc6f7a72acef3d3feeeb6c (patch)
tree094ba2238e5596358b6ae4db5789c7d1fee4ecb7 /test/sieve.go
parentcd8f4cd2068964bfa12e10cd094d41ddd725af4f (diff)
downloadgo-4f61fc96b2788be7cbfc6f7a72acef3d3feeeb6c.tar.gz
go-4f61fc96b2788be7cbfc6f7a72acef3d3feeeb6c.zip
test: remove semiocolons.
The ken directory is untouched so we have some examples with explicit semis. R=gri CC=golang-dev https://golang.org/cl/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 ec2ce446e5..4fa1115824 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
}
}