mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
24 lines
324 B
Go
24 lines
324 B
Go
|
|
package goose
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"text/template"
|
||
|
|
)
|
||
|
|
|
||
|
|
// common routines
|
||
|
|
|
||
|
|
func writeTemplateToFile(path string, t *template.Template, data interface{}) (string, error) {
|
||
|
|
f, e := os.Create(path)
|
||
|
|
if e != nil {
|
||
|
|
return "", e
|
||
|
|
}
|
||
|
|
defer f.Close()
|
||
|
|
|
||
|
|
e = t.Execute(f, data)
|
||
|
|
if e != nil {
|
||
|
|
return "", e
|
||
|
|
}
|
||
|
|
|
||
|
|
return f.Name(), nil
|
||
|
|
}
|