From 6e2ad84bb7f0ba23c93b800d36435bb8bcd80cd8 Mon Sep 17 00:00:00 2001 From: Jan Bachmann <3010330@stud.hs-mannheim.de> Date: Tue, 3 Dec 2024 10:31:57 +0100 Subject: [PATCH] =?UTF-8?q?Aufgabe3/simple1to10.go=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aufgabe3/simple1to10.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Aufgabe3/simple1to10.go diff --git a/Aufgabe3/simple1to10.go b/Aufgabe3/simple1to10.go new file mode 100644 index 0000000..1a8aeb0 --- /dev/null +++ b/Aufgabe3/simple1to10.go @@ -0,0 +1,20 @@ +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) + } +}