golang-exercises/fizzbuzz-threads/main.go

40 lines
408 B
Go
Raw Permalink Normal View History

package main
import (
"fmt"
)
func fizz(c chan int) {
num := <-c
if num%3 == 0 {
//str := "FIZZ"
c <- 1000
}
c <- 0
}
func buzz(c chan int) {
}
func fizzbuzz(c chan int) {
}
func main() {
fiz := make(chan int)
buz := make(chan int)
fizbuz := make(chan int)
go fizz(fiz)
go buzz(buz)
go fizzbuzz(fizbuz)
for i := 0; i < 100; i++ {
fiz <- i
fizzed := <-fiz
println(fizzed)
}
}