1
0
Fork 0
mirror of https://github.com/vbatts/talks.git synced 2024-11-16 05:28:37 +00:00
talks/2015/02-devconf.cz/primitive2.go

57 lines
836 B
Go
Raw Normal View History

2015-02-05 23:58:25 +00:00
// +build ignore
package main
import "fmt"
func main() {
// START1 OMIT
infos := map[string]Info{
"Michael": Info{
City: "Happyville",
Status: Open,
},
"Jan": Info{
City: "Confusville",
Status: Closed,
},
"Sean": Info{
City: "Septober",
Status: Complicated,
},
"Silvia": Info{
City: "Curiousville",
Status: Curios,
},
}
for name, info := range infos {
fmt.Printf("%q is %s in %q\n", name, info.Status, info.City)
}
// STOP1 OMIT
}
type Info struct {
City string
Status Status
}
type Status int
var (
Open = Status(0)
Closed = Status(1)
Complicated = Status(2)
Curios = Status(3)
)
func (s Status) String() string {
switch s {
case Open:
return "open"
case Closed:
return "closed"
case Complicated:
return "complicated"
}
return "hurr"
}