Skip to content

Commit

Permalink
fix on redeclared import path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sleygin committed Aug 25, 2024
1 parent 3dec19e commit 24844ac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ func getLastImportPart(srcPackageImport string) string {
func getSrcPackageAlias(imports []*ast.ImportSpec, srcPackageImport string) string {
var srcPackageImportAlias string
for _, imp := range imports {
var partToCompare string
if imp.Name != nil {
continue
partToCompare = imp.Name.Name
} else {
partToCompare = getLastImportPart(imp.Path.Value)
}

lastSrcPackagePart := getLastImportPart(srcPackageImport)
lastImpPart := getLastImportPart(imp.Path.Value)
if lastImpPart == lastSrcPackagePart {
if partToCompare == lastSrcPackagePart {
srcPackageImportAlias = "__" + lastSrcPackagePart
}
}
Expand Down

0 comments on commit 24844ac

Please sign in to comment.