我正在尝试显示健身课程列表(瑜伽、普拉提等)。对于每种课程类型,都有几个课程,所以我想将所有瑜伽课程和所有普拉提课程等分组。
我做了这个功能来获取切片并制作它的地图
func groupClasses(classes []entities.Class) map[string][]entities.Class {
classMap := make(map[string][]entities.Class)
for _, class := range classes {
classMap[class.ClassType.Name] = append(classMap[class.ClassType.Name], class)
}
return classMap
}
现在的问题是我如何遍历它,根据http://golang.org/pkg/text/template/,您需要以.Key格式访问它,我不知道密钥(除非我也通过了一个切片键进入模板)。我如何在我的视图中打开这张地图。
我目前所拥有的是
{{ . }}
显示如下内容:
map[Pilates:[{102 PILATES ~/mobifit/video/ocen.mpg 169 40 2014-05-03 23:12:12 +0000 UTC 2014-05-03 23:12:12 +0000 UTC 1899-12-30 00:00:00 +0000 UTC {PILATES Pilates 1 2014-01-22 21:46:16 +0000 UTC} {1 leebrooks0@gmail.com password SUPERADMIN Lee Brooks {Male true} {1990-07-11 00:00:00 +0000 UTC true} {1.85 true} {88 true} 2014-01-22 21:46:16 +0000 UTC {0001-01-01 00:00:00 +0000 UTC false} {0001-01-01 00:00:00 +0000 UTC false} {0001-01-01 00:00:00 +0000 UTC false}} [{1 Mat 2014-01-22 21:46:16 +0000 UTC}]} {70 PILATES ~/mobifit/video/ocen.mpg 119 66 2014-03-31 15:12:12 +0000 UTC 2014-03-31 15:12:12 +0000 UTC 1899-12-30 00:00:00 +0000 UTC
12345678_0001
相关分类