From 17cc53fb1e3a6d0abcc5ea3d651b7b4ec4cd44d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20P=C3=B3=C5=82grabia?= Date: Mon, 17 Jan 2022 22:36:10 +0100 Subject: [PATCH] Adding go func examples and global .gitignore. --- .gitignore | 2 ++ 2022/01/go_func1/Program.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .gitignore create mode 100644 2022/01/go_func1/Program.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29b636a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +*.iml \ No newline at end of file diff --git a/2022/01/go_func1/Program.go b/2022/01/go_func1/Program.go new file mode 100644 index 0000000..0decab3 --- /dev/null +++ b/2022/01/go_func1/Program.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "github.com/mariomac/gostream/stream" +) + +func isEven(n int) bool { + return n%2 == 0 +} + +func main() { + fmt.Println("Hello World") + stream.Of(0, 1, 2, 3, 4). + Filter(func(n int) { + return n%2 == 0 + }). + ForEach(func(n int) { + fmt.Printf("Number %v\n", n) + }) +}