clair/vendor/bitbucket.org/liamstask/goose/lib/goose/util.go
2016-02-24 16:34:54 -05:00

41 lines
567 B
Go

package goose
import (
"io"
"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
}
func copyFile(dst, src string) (int64, error) {
sf, err := os.Open(src)
if err != nil {
return 0, err
}
defer sf.Close()
df, err := os.Create(dst)
if err != nil {
return 0, err
}
defer df.Close()
return io.Copy(df, sf)
}