Skip to content

Commit

Permalink
chore: more comment
Browse files Browse the repository at this point in the history
  • Loading branch information
haunt98 committed Nov 28, 2022
1 parent 7e1dc2d commit 6119f35
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/imports/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ func (ft *Formatter) formatFile(path string) error {
}

// Copy from goimports, gofumpt, goimports-reviser
// First parse ast
//
// # Then group imports
//
// # Then format imports
//
// # Then update ast decls
//
// Then print ast
func (ft *Formatter) formatImports(
path string,
pathBytes []byte,
Expand Down Expand Up @@ -347,6 +356,7 @@ func (ft *Formatter) groupImportSpecs(
}

// Copy from goimports-reviser
// Insert empty import (empty path) between groups
func (ft *Formatter) formatImportSpecs(
importSpecs []ast.Spec,
groupedImportSpecs map[string][]*ast.ImportSpec,
Expand Down Expand Up @@ -394,6 +404,8 @@ func (ft *Formatter) formatImportSpecs(
}

// Copy from goimports-reviser
// Get module name from go.mod of path
// If current path doesn't have go.mod, recursive find its parent path
func (ft *Formatter) moduleName(path string) (string, error) {
ft.muModuleNames.RLock()
if pkgName, ok := ft.moduleNames[path]; ok {
Expand Down

0 comments on commit 6119f35

Please sign in to comment.