From e8da61d1ee51c6ddf193f68aed3f89dde19a9519 Mon Sep 17 00:00:00 2001 From: sebastian Date: Tue, 7 Nov 2023 13:41:02 +0100 Subject: [PATCH] lecture 65 --- Section6/63.go | 11 ++++++++--- Section6/65.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 Section6/65.go diff --git a/Section6/63.go b/Section6/63.go index 2f69b4d..5d859d1 100644 --- a/Section6/63.go +++ b/Section6/63.go @@ -2,13 +2,18 @@ package main import "fmt" -func main () { +func main() { i := 0 loop: - if i < 5{ + if i < 5 { fmt.Println(i) i++ goto loop } -} \ No newline at end of file + // THIS IS AN ERROR + // goto todo + // x := 5 + // todo: + // fmt.Println("something here") +} diff --git a/Section6/65.go b/Section6/65.go new file mode 100644 index 0000000..fc8b434 --- /dev/null +++ b/Section6/65.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + language := "golang" + + switch language { + case "Python": + fmt.Println("You are learnig Python! You don't use curly braces but indentation!!") + + case "go", "golang": + fmt.Println("Good, go for Go! You are using curly braces {}!") + + default: + fmt.Println("Any other programming language is a good start!") + } + + n := 5 + switch true { + case n%2 == 0: + fmt.Println("Even number") + case n%2 != 0: + fmt.Println("Odd number") + default: + fmt.Println("Never here!!") + } + + hour := time.Now().Hour() + fmt.Println(hour) + + switch { + case hour < 12: + fmt.Println("Good morning") + case hour < 17: + fmt.Println("Good afernoon") + default: + fmt.Println("Good evening") + } +}