PR3-Go-Vortrag/Aufgabe3/simple1to10.go

21 lines
227 B
Go

package main
import "fmt"
func count(ch chan int) {
for i := 1; i <= 10; i++ {
ch <- i
}
close(ch)
}
func main() {
channel := make(chan int)
go count(channel)
for num := range channel {
fmt.Println(num)
}
}