Skip to content

Commit

Permalink
run go/format on generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ernesto-jimenez committed Sep 25, 2016
1 parent 75f4cfe commit 4b9bfb8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion _codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"go/ast"
"go/build"
"go/doc"
"go/format"
"go/importer"
"go/parser"
"go/token"
Expand Down Expand Up @@ -77,13 +78,18 @@ func generateCode(importer imports.Importer, funcs []testFunc) error {
}
}

code, err := format.Source(buff.Bytes())
if err != nil {
return err
}

// Write file
output, err := outputFile()
if err != nil {
return err
}
defer output.Close()
_, err = io.Copy(output, buff)
_, err = io.Copy(output, bytes.NewReader(code))
return err
}

Expand Down

0 comments on commit 4b9bfb8

Please sign in to comment.