tartrazine/internal/code-generator/generator/generator.go
2017-06-15 10:07:22 +02:00

23 lines
512 B
Go

package generator
import (
"go/format"
"io/ioutil"
)
// File is the function's type that generate source file from a file to be parsed, linguist's samples dir and a template.
type File func(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error
func formatedWrite(outPath string, source []byte) error {
formatedSource, err := format.Source(source)
if err != nil {
return err
}
if err := ioutil.WriteFile(outPath, formatedSource, 0666); err != nil {
return err
}
return nil
}