-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (49 loc) · 880 Bytes
/
main.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
62
63
64
65
66
67
package main
import "fmt"
// this is a comment
var lol string = "lol"
func main() {
var x string = "This is a string!"
fmt.Println(x)
//for_loop()
//array_ex()
//slice_ex()
maps_ex()
}
func maps_ex() {
x := make(map[string]int)
x["key"] = 10
fmt.Println(x["key"])
delete(x,1)
}
func slice_ex() {
arr := []float64{1,2,3,4,5}
x := arr[1:4]
fmt.Println(x)
}
func array_ex() {
var x [5]float64
x[0] = 98
x[1] = 93
x[2] = 77
x[3] = 82
x[4] = 83
var total float64 = 0
for _, value := range x{
total += value
}
fmt.Println(total / float64(len(x)))
}
func for_loop(){
for i := 1; i <= 10; i++ {
switch i {
case 0: fmt.Println("Zero")
case 1: fmt.Println("One")
case 2: fmt.Println("Two")
case 3: fmt.Println("Three")
case 4: fmt.Println("Four")
case 5: fmt.Println("Five")
default: fmt.Println("Unknown Number")
}
}
}