chore: more comment

main
sudo pacman -Syu 2022-11-28 12:22:10 +07:00
parent 7e1dc2df7d
commit 6119f3562b
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 12 additions and 0 deletions

View File

@ -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,
@ -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,
@ -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 {