Include gofmt in the code generation process.

This commit is contained in:
John Beisley 2013-12-31 17:16:47 +00:00
parent 50cfea8d4f
commit 38405bcf8d

View File

@ -14,6 +14,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"os/exec"
"path" "path"
"path/filepath" "path/filepath"
"regexp" "regexp"
@ -173,7 +174,22 @@ func (dcp *DCP) writePackage(outDir string) error {
return err return err
} }
defer packageFile.Close() defer packageFile.Close()
return packageTmpl.Execute(packageFile, dcp) gofmt := exec.Command("gofmt")
gofmt.Stdout = packageFile
gofmtWriter, err := gofmt.StdinPipe()
if err != nil {
return err
}
if err = gofmt.Start(); err != nil {
return err
}
if err = packageTmpl.Execute(gofmtWriter, dcp); err != nil {
gofmtWriter.Close()
gofmt.Wait()
return err
}
gofmtWriter.Close()
return gofmt.Wait()
} }
func (dcp *DCP) processSCPDFile(file *zip.File) { func (dcp *DCP) processSCPDFile(file *zip.File) {