github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/go4gophers/organs.go (about) 1 // +build OMIT 2 3 package main 4 5 import "fmt" 6 7 type Organ struct { 8 Name string 9 Weight Grams 10 } 11 12 func (o *Organ) String() string { return fmt.Sprintf("%v (%v)", o.Name, o.Weight) } 13 14 type Grams int 15 16 func (g Grams) String() string { return fmt.Sprintf("%dg", int(g)) } 17 18 func main() { 19 s := []*Organ{{"brain", 1340}, {"heart", 290}, 20 {"liver", 1494}, {"pancreas", 131}, {"spleen", 162}} 21 22 for _, o := range s { 23 fmt.Println(o) 24 } 25 }