Skip to content

Commit

Permalink
Merge pull request #63 from sev-2/feature/consistent-import
Browse files Browse the repository at this point in the history
feat: sort attributes to produce consistent values
  • Loading branch information
toopay authored Sep 8, 2024
2 parents 9066415 + fa7b5b1 commit 5cc70d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/generator/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package generator
import (
"fmt"
"path/filepath"
"sort"
"strings"
"text/template"

Expand Down Expand Up @@ -352,5 +353,9 @@ func BuildRelationFields(table objects.Table, relations []state.Relation) (mappe
mappedRelations = append(mappedRelations, r)
}

sort.Slice(mappedRelations, func(i, j int) bool {
return len(mappedRelations[i].Table) < len(mappedRelations[j].Table)
})

return
}
2 changes: 2 additions & 0 deletions pkg/generator/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"path/filepath"
"regexp"
"sort"
"strings"
"text/template"

Expand Down Expand Up @@ -208,6 +209,7 @@ func generateRpcItem(folderPath string, projectName string, function *objects.Fu
for key := range importsMap {
importsPath = append(importsPath, key)
}
sort.Strings(importsPath)

// set data
data := GenerateRpcData{
Expand Down

0 comments on commit 5cc70d7

Please sign in to comment.