mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-12 22:42:23 +00:00
23 lines
512 B
Go
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
|
|
}
|