Golang parse template from string and to string
- related
- Golang
t, err := template.New("Test").Parse("Hello {{.Name}}, Good Morning!")
if err != nil {
return err
}
data := struct{
Name: string
}{
Name: "Jimmy"
}
var tpl bytes.Buffer
err = t.Execute(&tpl, data)
if err != nil {
return err
}
result = tpl.String()