feat: sort import (wip)

main
sudo pacman -Syu 2022-11-26 02:18:02 +07:00
parent 1d3685f57b
commit c921e92d75
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 9 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"sort"
"strings" "strings"
"golang.org/x/tools/go/packages" "golang.org/x/tools/go/packages"
@ -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 return result, nil
} }