I am new to golang. I would like to pass multiple variables to html. So I have a type like:
type Variables struct {
UserNames []string
Checks []string
}
pagevarible with passed the correct values
var PageVars Variables
PageVars = Variables{
UserNames: ulist,
Checks: check,
}
log.Println("ulist",ulist)
err = tpl.Execute(w, PageVars) //execute the template and pass it to index page
if err != nil { // if there is an error
log.Print("template executing error: ", err) //log it on terminal
}
And I want to pass both UserNames and Checks to html template, something like:
{{range .UserNames .Checks}}
{{.UserNames}}: <input type="checkbox" name="email" value={{. UserNames}} {{.Checks}}/><br />
{{end}}
But it didn't work out. Can anyone correct my syntax? Thanks a lot.