mirror of
https://github.com/vbatts/talks.git
synced 2024-12-28 17:46:31 +00:00
35 lines
369 B
Go
35 lines
369 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
IN_UTERO = iota
|
||
|
NEW_BORN
|
||
|
GROWING
|
||
|
LIVING
|
||
|
DYING
|
||
|
DEAD
|
||
|
)
|
||
|
|
||
|
type Person struct {
|
||
|
Name string
|
||
|
Dob *time.Time
|
||
|
State byte
|
||
|
}
|
||
|
|
||
|
func (p *Person) DobString() string {
|
||
|
if (p.Dob == nil) {
|
||
|
return ""
|
||
|
}
|
||
|
return p.Dob.String()
|
||
|
}
|
||
|
|
||
|
func (p *Person) ComeToLife() {
|
||
|
t := time.Now()
|
||
|
p.Dob = &t
|
||
|
p.State = NEW_BORN
|
||
|
}
|
||
|
|