分组结构的最惯用方式?

I'm trying to group together a set of structs by multiple keys. In the example below, cats are grouped together with their age and name used as the key. Is there a more idiomatic, generic or just a better way to do this in Go?

I need to apply "group by" for multiple types of different structs, so this could get very verbose.

http://play.golang.org/p/-CHDQ5iPTR

package main

import (
    "errors"
    "fmt"
    "math/rand"
)

type Cat struct {
    CatKey
    Kittens int
}

type CatKey struct {
    Name string
    Age  int
}

func NewCat(name string, age int) *Cat {
    return &Cat{CatKey: CatKey{Name: name, Age: age}, Kittens: rand.Intn(10)}
}

func GroupCatsByNameAndAge(cats []*Cat) map[CatKey][]*Cat {
    groupedCats := make(map[CatKey][]*Cat)
    for _, cat := range cats {
        if _, ok := groupedCats[cat.CatKey]; ok {
            groupedCats[cat.CatKey] = append(groupedCats[cat.CatKey], cat)
        } else {
            groupedCats[cat.CatKey] = []*Cat{cat}
        }
    }

    return groupedCats
}

func main() {
    cats := []*Cat{
        NewCat("Leeroy", 12),
        NewCat("Doofus", 14),
        NewCat("Leeroy", 12),
        NewCat("Doofus", 14),
        NewCat("Leeroy", 12),
        NewCat("Doofus", 14),
        NewCat("Leeroy", 12),
        NewCat("Doofus", 14),
        NewCat("Leeroy", 12),
        NewCat("Doofus", 14),
    }

    groupedCats := GroupCatsByNameAndAge(cats)

    Assert(len(groupedCats) == 2, "Expected 2 groups")
    for _, value := range groupedCats {
        Assert(len(value) == 5, "Expected 5 cats in 1 group")
    }

    fmt.Println("Success")
}

func Assert(b bool, msg string) {
    if !b {
        panic(errors.New(msg))
    }
}

Here is a more idiomatic version of the GroupCatsByNameAndAge function. Note that a if groupedCats doesn't have a cat.CatKey then groupedCats[cat.CatKey] will be nil, however nil is a perfectly acceptable value for append. Playground

func GroupCatsByNameAndAge(cats []*Cat) map[CatKey][]*Cat {
    groupedCats := make(map[CatKey][]*Cat)
    for _, cat := range cats {
        groupedCats[cat.CatKey] = append(groupedCats[cat.CatKey], cat)
    }
    return groupedCats
}