-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.go
68 lines (54 loc) · 1.03 KB
/
object.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
68
package personstore
import (
"reflect"
"time"
)
type Object interface {
GetKind() string
GetId() string
GetName() string
SetID(id string)
SetName(name string)
}
type Person struct {
Name string `json:"name"`
ID string `json:"id"`
LastName string `json:"last_name"`
BirthDate time.Time `json:"birthday"`
}
func (p *Person) GetKind() string {
return reflect.TypeOf(p).String()
}
func (p *Person) GetId() string {
return p.ID
}
func (p *Person) GetName() string {
return p.Name
}
func (p *Person) SetID(id string) {
p.ID = id
}
func (p *Person) SetName(name string) {
p.Name = name
}
type Animal struct {
Name string `json:"name"`
ID string `json:"id"`
Type string `json:"type"`
OwnerID string `json:"owner_id"`
}
func (a *Animal) GetKind() string {
return reflect.TypeOf(a).String()
}
func (a *Animal) GetId() string {
return a.ID
}
func (a *Animal) GetName() string {
return a.Name
}
func (a *Animal) SetID(id string) {
a.ID = id
}
func (a *Animal) SetName(name string) {
a.Name = name
}