I'm passing an array of structs to my template, the data is there but I can't find a way to access specific data, I tried many things already, here it is
My Struct
type Data struct {
Destination string
IData interface{}
}
then in my controller I have
users := []models.User {}
userRow := models.User{Name: "jon", Email: "jon@mail.com"}
users = append(users, userRow)
users2 := users
data := models.Data{
Destination: "content",
IData: users,
}
data2 := models.Data{
Destination: "content",
IData: users2,
}
dataFinal := []models.Data{}
dataFinal = append(dataFinal, data)
dataFinal = append(dataFinal, data2)
and this is my template, though this didn't seem to work, it does show the raw data but can't seem to access the name specifically.
{{define "content"}}
<h2>THIS IS THE BODY CONTENT</h2>
<ul>
{{.}}
{{range .}}
<li>{{.}}</li>
{{end}}
</ul>
{{end}}
edit: project: https://github.com/og2/go-og2-mvc
you may wanna run:
go get github.com/go-sql-driver/mysql
go get github.com/julienschmidt/httprouter
for it to work and should be just fine!