-
Notifications
You must be signed in to change notification settings - Fork 1
/
If.go
61 lines (47 loc) · 896 Bytes
/
If.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
fmt.Println("Simple If ->")
isGoAwesome := true
if isGoAwesome {
fmt.Println("Go is awesome")
} else {
fmt.Println("Go should go away!")
}
fmt.Println()
if x := 100; x < sample() {
fmt.Println(x, "is lower than Sample")
} else {
fmt.Println(x, "is higher than Sample")
}
//fmt.Println(x, "Cant access x here")
fmt.Println()
fmt.Print("The Go app is currently running on ")
switch os := runtime.GOOS; os {
case "darwin":
fmt.Println("OS X.")
case "linux":
fmt.Println("Linux.")
default:
// freebsd, openbsd,
// plan9, windows...
fmt.Printf("%s.\n", os)
}
fmt.Println()
t := time.Now()
switch {
case t.Hour() < 12:
fmt.Println("Good morning!")
case t.Hour() < 17:
fmt.Println("Good afternoon.")
default:
fmt.Println("Good evening.")
}
}
func sample() int {
return 1337
}