forked from GoesToEleven/GolangTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (43 loc) · 770 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
package main
import "fmt"
type vehicle struct {
Seats int
MaxSpeed int
Color string
}
type car struct {
vehicle
Wheels int
Doors int
}
type plane struct {
vehicle
Jet bool
}
type boat struct {
vehicle
Length int
}
func main() {
prius := car{}
tacoma := car{}
bmw528 := car{}
cars := []car{prius, tacoma, bmw528}
boeing747 := plane{}
boeing757 := plane{}
boeing767 := plane{}
planes := []plane{boeing747, boeing757, boeing767}
sanger := boat{}
nautique := boat{}
malibu := boat{}
boats := []boat{sanger, nautique, malibu}
for key, value := range cars {
fmt.Println(key, " - ", value)
}
for key, value := range planes {
fmt.Println(key, " - ", value)
}
for key, value := range boats {
fmt.Println(key, " - ", value)
}
}