This commit is contained in:
Celogeek 2021-12-31 17:28:18 +01:00
parent e86ab01766
commit 10c210a383
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
2 changed files with 7 additions and 7 deletions

View File

@ -10,9 +10,9 @@ type Category struct {
} }
func (c *Categories) Names() []string { func (c *Categories) Names() []string {
names := []string{} names := make([]string, len(*c))
for _, category := range *c { for i, category := range *c {
names = append(names, category.Name) names[i] = category.Name
} }
return names return names
} }

View File

@ -17,13 +17,13 @@ type Tag struct {
} }
func (c Tags) NamesWithAgeAt(createdAt TimeResult) []string { func (c Tags) NamesWithAgeAt(createdAt TimeResult) []string {
names := []string{} names := make([]string, len(c))
for _, category := range c { for i, category := range c {
bd := category.Birthdate.AgeAt(createdAt) bd := category.Birthdate.AgeAt(createdAt)
if bd != "" { if bd != "" {
names = append(names, fmt.Sprintf("%s (%s)", category.Name, bd)) names[i] = fmt.Sprintf("%s (%s)", category.Name, bd)
} else { } else {
names = append(names, category.Name) names[i] = category.Name
} }
} }
return names return names