var funcMap = template.FuncMap{
"sayHello": sayHello,
}
func sayHello() string {
return "Hello World"
}
tmpl, err := template.New("base").Funcs(funcMap).ParseFiles(html_path)
tmpl.Execute(writer, nil){{ sayHelo }}runtime error: invalid memory address or nil pointer dereference.Misspell.
var funcMap = template.FuncMap{
"whatEver": sayHello,
}
Then you
invoke in html using {{.whatEver}}, because now you invoke
using the map's key, not its value.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'm trying to add custom function using FuncMap:
map[whatEver:0x400b0]0x400b0--