Skip to content

Commit

Permalink
feat: sort import (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
haunt98 committed Nov 25, 2022
1 parent 1d3685f commit c921e92
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/imports/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"os"
"path/filepath"
"sort"
"strings"

"golang.org/x/tools/go/packages"
Expand Down Expand Up @@ -204,6 +205,14 @@ func (ft *Formatter) groupImports(importsAST map[string]*ast.ImportSpec) (map[st
}
}

// TODO: not sure if this match gofumpt output, but at lease it is sorted
sort.Strings(result[stdImport])
sort.Strings(result[thirdPartyImport])
if ft.companyPrefix != "" {
sort.Strings(result[companyImport])
}
sort.Strings(result[localImport])

return result, nil
}

Expand Down

0 comments on commit c921e92

Please sign in to comment.