I want to pass two data objects to Go Template. One is a MongoDB query result and other is an integer array.
MongoDB Query:-
var results []User
sess,
You should define a struct populated with the database results query, then assign that struct to the Execute method.
tmpl.Execute require a Writer interface and a struct
type Inventory struct {
Material string
Count uint
}
items := Inventory{"trouser", 1}
if err := GetTemplate("list").Execute(w, items); err != nil {
// ... do your work
}