Skip to content

Commit

Permalink
sort packages (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy authored Aug 21, 2024
1 parent 7d9ad60 commit adf6a0e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions generator/code_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,14 @@ func (f *File) Imports() []*Import {
importPathMap[pkg.ImportPath] = struct{}{}
importAliasMap[pkg.Name] = struct{}{}
}
sortedPkgs := make([]*resolver.GoPackage, 0, len(f.pkgMap))
for pkg := range f.pkgMap {
sortedPkgs = append(sortedPkgs, pkg)
}
sort.Slice(sortedPkgs, func(i, j int) bool {
return sortedPkgs[i].ImportPath < sortedPkgs[j].ImportPath
})
for _, pkg := range sortedPkgs {
addImport(pkg)
}
sort.Slice(imports, func(i, j int) bool {
Expand Down

0 comments on commit adf6a0e

Please sign in to comment.