mirror of
https://github.com/vbatts/talks.git
synced 2025-05-24 13:52:30 +00:00
2015-devnation: copying devconf talk
This commit is contained in:
parent
5149d7ec5e
commit
65363d37c3
18 changed files with 482 additions and 0 deletions
56
2015/06-devnation-golang-good-bad-ugly/primitive2.go
Normal file
56
2015/06-devnation-golang-good-bad-ugly/primitive2.go
Normal file
|
@ -0,0 +1,56 @@
|
|||
// +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"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue