Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created August 7, 2012 21:21
Show Gist options
  • Save leejarvis/3289487 to your computer and use it in GitHub Desktop.
Save leejarvis/3289487 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Person struct {
Name string
}
func (p *Person) String() string {
return fmt.Sprintf("%s @ %p", p.Name, &p)
}
func main() {
people := []*Person{}
p1 := &Person{"Lee"}
p2 := &Person{"Bob"}
people = append(people, p1, p2)
for _, person := range people {
fmt.Println(person)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment