// Source - https://stackoverflow.com/a/59083271 // Posted by wasmup, modified by community. See post 'Timeline' for change history // Retrieved 2026-05-03, License - CC BY-SA 4.0 package main import ( "fmt" "os" "text/template" ) func main() { name := "AlphaGo" fmt.Printf("I am %s\n", name) t := template.Must(template.New("my").Parse("I am {{.Name}}\n")) t.Execute(os.Stdout, struct{ Name string }{name}) // I am AlphaGo t2 := template.Must(template.New("my").Parse("I am {{.name}}\n")) t2.Execute(os.Stdout, map[string]string{"name": name}) // I am AlphaGo t3 := template.Must(template.New("my").Parse("I am {{.}}\n")) t3.Execute(os.Stdout, name) // I am AlphaGo }