i've been researching for a while now but could not find anything.
For Example
var name = "tom"
sentence := "My Name is #{name}"
In JS this works with ${var} and in ruby with #{var}
So are there Template Strings in GoLang ?
Thanks for your help
The Solution is
sentence := fmt.Sprintf("My Name is %s", name)
The better way is using template. It allows you to specify a name.
sentence := "My Name is {{ .name }}"
templ := template.Must(template.New("myname").Parse(sentence))
templ.Execute(os.Stdout, map[string]interface{}{
"name": "tom",
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With