feat: sort import (wip)
parent
1d3685f57b
commit
c921e92d75
|
@ -9,6 +9,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue