-
Notifications
You must be signed in to change notification settings - Fork 0
/
13_switch.go
57 lines (50 loc) · 854 Bytes
/
13_switch.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
package main
import (
"fmt"
"runtime"
)
func main() {
for i := 1; i <= 10; i++ {
//if i == 1 {
// fmt.Println("Satu")
//} else if i == 2 {
// fmt.Println("Dua")
//} else if i == 3 {
// fmt.Println("Tiga")
//} else if i == 4 {
// fmt.Println("Empat")
//} else if i == 5 {
// fmt.Println("Lima")
//} else {
// fmt.Println("Gak Tau")
//}
//switch {
switch i {
//case i==1:
case 1:
fmt.Println("Satu")
case 2:
fmt.Println("Dua")
case 3:
fmt.Println("Tiga")
case 4:
fmt.Println("Empat")
case 5:
fmt.Println("Lima")
default:
fmt.Println("Gak Tau")
}
}
fmt.Println("---")
sistemOperasi := runtime.GOOS
switch sistemOperasi {
case "darwin":
fmt.Println("Mac")
case "windows":
fmt.Println("Windows")
case "linux":
fmt.Println("Linux")
default:
fmt.Println("Gakt Tau")
}
}