I use the following code
var data struct {
File FZR
API API
}
const tmpl = `
{{- range .File.Modules}}
# in context of {{.Name}}
echo {{.EchoText}}
{{end}}`
func EchoText(m mts) string {
return m.Type
}
and like this its not working, now I change it to
func (m mts) EchoText() string {
return m.Type
}
it will work but I want to make it work with the first option, how can I do it ? I mean update the template ...
update: as approva answer https://golang.org/pkg/text/template/#example_Template_func
but there is only string, how can I register the EchoText