github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/internal/tprint.go (about) 1 package internal 2 3 import ( 4 "bytes" 5 "text/template" 6 ) 7 8 // Tprintf renders a string from a given template string and field values 9 func Tprintf(tmpl string, data map[string]interface{}) string { 10 t := template.Must(template.New("").Parse(tmpl)) 11 buf := &bytes.Buffer{} 12 if err := t.Execute(buf, data); err != nil { 13 return "" 14 } 15 return buf.String() 16 }