package grils import ( "database/sql" "fmt" "strconv" "strings" "time" "github.com/lib/pq" ) type DataSource int const ( DataSourceACD DataSource = iota DataSourceAniDB ) type Gril struct { ID int KanjiName string RomajiName string OtherNames []string Age sql.NullInt64 Birthday pq.NullTime Tags []string ForeignIDs map[DataSource]int UpdatedAt time.Time Lists []int } func (g *Gril) Slug() string { if g.RomajiName == "" { return strconv.Itoa(g.ID) } return fmt.Sprintf( "%d/%s", g.ID, strings.Replace(g.RomajiName, " ", "", -1)) }