grype/internal/stringutil/tprint.go
Olivier Boudet 9050883715
feat(outputs): allow to set multiple outputs (#648) (#1346)
* feat(outputs): allow to set multiple outputs (#648)

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>
Signed-off-by: Olivier Boudet <olivier.boudet@cooperl.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* feat(outputs): allow to set multiple outputs (#648)

review

Signed-off-by: Olivier Boudet <olivier.boudet@cooperl.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* use syft format writter pattern and de-emphasize presenter package

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>
Signed-off-by: Olivier Boudet <olivier.boudet@cooperl.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
2023-07-11 17:37:17 +00:00

16 lines
354 B
Go

package stringutil
import (
"bytes"
"text/template"
)
// Tprintf renders a string from a given template string and field values
func Tprintf(tmpl string, data map[string]interface{}) string {
t := template.Must(template.New("").Parse(tmpl))
buf := &bytes.Buffer{}
if err := t.Execute(buf, data); err != nil {
return ""
}
return buf.String()
}