rlp/rlpgen: update

This commit is contained in:
Felix Lange 2025-06-19 17:06:02 +02:00
parent 39c1dd1f61
commit 00a5387995

View file

@ -139,16 +139,16 @@ func (ctx *genContext) addImport(pkg *types.Package) string {
if p, exists := ctx.imports[pkg.Path()]; exists { if p, exists := ctx.imports[pkg.Path()]; exists {
return p.alias return p.alias
} }
baseName := pkg.Name() var (
alias := baseName baseName = pkg.Name()
counter := 1 alias = baseName
counter = 1
// If the base name conflicts with any existing import, add a numeric suffix )
// If the base name conflicts with an existing import, add a numeric suffix.
for ctx.hasAlias(alias) { for ctx.hasAlias(alias) {
alias = fmt.Sprintf("%s%d", baseName, counter) alias = fmt.Sprintf("%s%d", baseName, counter)
counter++ counter++
} }
ctx.imports[pkg.Path()] = genImportPackage{alias, pkg} ctx.imports[pkg.Path()] = genImportPackage{alias, pkg}
return alias return alias
} }