-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.go
56 lines (40 loc) · 779 Bytes
/
3.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
package main
import "fmt"
type worker struct {
pers *human
exp int
}
type human struct {
name string
age int
}
type hr struct {
wor *worker
country string
field string
}
type coder struct {
wor worker
primaryTech string
secondaryTech string
}
func (receiver *human) HappyBirthday() {
fmt.Printf("Happy Birthday yo you %v!\n", (*receiver).name)
}
func (receiver *human) promoted() string {
res := "You are promoted!"
return res
}
func (receiver *human) yourAge5YearsAgo() int {
res := (*receiver).age - 5
return res
}
func main() {
q := human{"James", 29}
q.HappyBirthday()
fmt.Println(q.promoted())
fmt.Printf("Your age 5 yers ago was %d", q.yourAge5YearsAgo())
//panic("some problem")
var r *human
fmt.Printf(r.age)
}