I have a mustache template like:
{{#attributes}}
func (event {{fileNameRoot}}) Get{{Name}}() string {
return event.{{Name}}
}
{{/attributes}}
which outputs:
func (event JustATest) GetuserName() string {
return event.userName
}
What I want is:
func (event JustATest) GetUserName() string {
return event.UserName
}
How to achieve this? I am using Go and the mustache library github.com/hoisie/mustache.
The go code looks like:
data := map[string]interface{}{
"fileNameRoot": "JustATest",
"attributes": schema.Attributes,
}
out, err := mustache.RenderFile("templates/test.go.mustache", data)
if err != nil {
panic(err)
}
You can use this useful library
github.com/iancoleman/strcaseto convert strings to different cases. In your case, you can convertschema.Attributesright before sending it as argument: