Changing to fixed ordering for generator when multiple types in single file

This commit is contained in:
Kenneth Shaw
2017-02-14 15:28:23 +07:00
parent 99e922cf9d
commit e1682275f9
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -11,6 +11,7 @@ import (
"os"
"os/exec"
"path/filepath"
"sort"
)
const genPackage = "github.com/mailru/easyjson/gen"
@@ -59,6 +60,7 @@ func (g *Generator) writeStub() error {
fmt.Fprintln(f, ")")
}
sort.Strings(g.Types)
for _, t := range g.Types {
fmt.Fprintln(f)
if !g.NoStdMarshalers {
@@ -114,6 +116,8 @@ func (g *Generator) writeMain() (path string, err error) {
if g.NoStdMarshalers {
fmt.Fprintln(f, " g.NoStdMarshalers()")
}
sort.Strings(g.Types)
for _, v := range g.Types {
fmt.Fprintln(f, " g.Add(pkg.EasyJSON_exporter_"+v+"(nil))")
}
+1 -1
View File
@@ -153,7 +153,7 @@ func (g *Generator) printHeader() {
sort.Strings(aliases)
fmt.Println("import (")
for _, alias := range g.imports {
for _, alias := range aliases {
fmt.Printf(" %s %q\n", alias, byAlias[alias])
}