Skip to content

Commit

Permalink
fixup: fix for comment
Browse files Browse the repository at this point in the history
Signed-off-by: 170210 <j170210@icloud.com>
  • Loading branch information
170210 committed Aug 9, 2023
1 parent d5e2d85 commit 42c625c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/error_doc/generator/error_docs_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ type moduleInfo struct {
errorDict []errorInfo
}

type sortByCodespace []*moduleInfo

func (b sortByCodespace) Len() int { return len(b) }
func (b sortByCodespace) Less(i, j int) bool { return b[i].codespace < b[j].codespace }
func (b sortByCodespace) Swap(i, j int) { b[i], b[j] = b[j], b[i] }

func NewErrorDocumentGenerator(p string) *ErrorDocumentGenerator {
return &ErrorDocumentGenerator{
targetPath: p,
Expand Down Expand Up @@ -67,10 +73,10 @@ func (edg *ErrorDocumentGenerator) extractModuleName() error {
errorDict: []errorInfo{},
})
}
// sort keys and filepaths
// sort by key and codespace
for moduleName := range edg.errorDocument {
edg.modules = append(edg.modules, moduleName)
// sort.Strings(edg.errorDocument[moduleName])
sort.Sort(sortByCodespace(edg.errorDocument[moduleName]))
}
sort.Strings(edg.modules)
return nil
Expand Down

0 comments on commit 42c625c

Please sign in to comment.