0
我有一個sometihng類似的數據結構:我可以在Golang模板中使用另一個變量作爲關鍵字嗎?
map[string]SomeStructure
我有另外一個結構來封裝上面再加上額外的變量和其他結構,而這正是被髮送到模板:
type page struct {
Status map[string]SomeStructure
Database []string
}
在我的模板文件我想能夠做類似的事情
{{ range index .Database}}
{{ .Status "KEY".MemberVariableOfSomeStructure }}
{{ end }}
除了我希望「KEY」是動態的基於迭代g。數據庫值。