Your example works fine for me and on the playground. I adjusted the template a bit and used os.stdout
as writer.
func sample() error {
tpl, err := template.New("sample").Parse(`<a href="{{.sticker_set.url}}">{{.sticker_set.url}}</a>`)
if err != nil {
return err
}
data := map[string]interface{}{
"sticker_set": map[string]interface{}{
"url": "xyz",
},
}
if err := tpl.Execute(os.Stdout, data); err != nil {
return fmt.Errorf("Invalid template: %w", err)
}
return nil
}
Even tried it with different value types: Playground
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…