write a canonical header for machine-generated files

Signed-off-by: Denys Smirnov <denys@sourced.tech>
This commit is contained in:
Denys Smirnov
2018-04-28 16:12:03 +03:00
committed by Denys Smirnov
parent 40a21f8e0b
commit 7eafe024af
49 changed files with 167 additions and 742 deletions

View File

@ -2,16 +2,13 @@ package generator
import (
"bytes"
"text/template"
)
// Commit takes a commit and builds the source file from tmplPath. It complies with type File signature.
func Commit(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error {
buf := &bytes.Buffer{}
t := template.Must(template.New(tmplName).ParseFiles(tmplPath))
if err := t.Execute(buf, commit); err != nil {
if err := executeTemplate(buf, tmplName, tmplPath, commit, nil, nil); err != nil {
return err
}
return formatedWrite(outPath, buf.Bytes())
}