Created
August 7, 2012 21:21
-
-
Save leejarvis/3289487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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