構造体の配列

type Users []*User

func (us Users) IDs() []string {
    ids := make([]string, len(us))
    for i, u := range us {
        ids[i] = u.ID
    }
    return ids
}

func main() {
    us := Users{&User{ID: "1"}, &User{ID: "2"}}
    log.Print(us.IDs()) // ["1","2"]にが戻る
}