github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/helpers/template.go (about) 1 package helpers 2 3 import ( 4 "bytes" 5 "html/template" 6 ) 7 8 func Tprintf(tmpl string, param map[string]interface{}) string { 9 t := template.Must(template.New("Tprintf").Parse(tmpl)) 10 buf := &bytes.Buffer{} 11 if err := t.Execute(buf, param); err != nil { 12 return tmpl 13 } 14 return buf.String() 15 }