refactor: no need importNameAndPath

main
sudo pacman -Syu 2022-11-28 10:55:16 +07:00
parent 2345460d3d
commit a341a91279
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 12 additions and 16 deletions

View File

@ -354,12 +354,20 @@ func (ft *Formatter) formatImportSpecs(
}
for _, spec := range specs {
result = append(result, &ast.ImportSpec{
newSpec := &ast.ImportSpec{
Path: &ast.BasicLit{
Value: ft.importNameAndPath(spec),
Kind: token.IMPORT,
Value: spec.Path.Value,
Kind: token.STRING,
},
})
}
if spec.Name != nil {
newSpec.Name = &ast.Ident{
Name: spec.Name.Name,
}
}
result = append(result, newSpec)
}
}
}
@ -431,15 +439,3 @@ func (ft *Formatter) moduleName(path string) (string, error) {
return result, nil
}
func (ft *Formatter) importNameAndPath(importSpec *ast.ImportSpec) string {
if importSpec == nil {
return ""
}
if importSpec.Name != nil {
return importSpec.Name.String() + " " + importSpec.Path.Value
}
return importSpec.Path.Value
}