This is a creation in Article, where the information may have evolved or changed.
The Golang struct does not support nested loops that are displayed on the interface, so it uses the map data structure to store the data. Look directly at the code and effects. Beego Framework Service-side code: '
func (This *tablecontroller) get () { this. data["Thead"] = []string{"#", "name", "age"} //header data structure this. data["Tbody"] = []string{"Id", "Name", "Age"} //corresponding field value Personmap := make (map[string]string) personmap["Id"] = "1" personmap["Name"] = "Lisi" personmap["Age"] = "25 " personmap1 := make (map[string]string) personmap1[" Id "] = " 2 " personmap1[" Name "] = " Zhangsan " personmap1["Age"] = " person := make" (map[int64]map[string]string ) person[0] = personMap person[1] = Personmap1 fmt. PRINTLN (person) &nbsP; this. data["Person"] = person this. tplnames = "Table.tpl"}
' Front-end test code:
Final effect:
# Name Age
1 Lisi 25
2 Zhangsan 28