github.com/zkry/enry@v1.6.3/internal/code-generator/generator/generator.go (about) 1 package generator 2 3 import ( 4 "go/format" 5 "io/ioutil" 6 ) 7 8 // File is the function's type that generate source file from a file to be parsed, linguist's samples dir and a template. 9 type File func(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error 10 11 func formatedWrite(outPath string, source []byte) error { 12 formatedSource, err := format.Source(source) 13 if err != nil { 14 return err 15 } 16 17 if err := ioutil.WriteFile(outPath, formatedSource, 0666); err != nil { 18 return err 19 } 20 21 return nil 22 }