Use dot notation for enum variants

This commit is contained in:
pavel 2026-08-27 18:05:28 +02:00
commit 117d188194
13 changed files with 162 additions and 154 deletions

View file

@ -97,7 +97,7 @@ func (g *goGenerator) validateMapping(source, target, path string, seen map[stri
}
for _, sourceVariant := range sourceEnum.Variants {
targetVariant := enumVariant(targetEnum, sourceVariant.Name)
variantPath := path + "::" + sourceVariant.Name
variantPath := path + "." + sourceVariant.Name
if targetVariant == nil {
return fmt.Errorf("cannot map %s: target enum %s has no compatible variant", variantPath, targetEnum.Name)
}
@ -158,7 +158,7 @@ func (g *goGenerator) emitMapping(pair mappingPair) error {
g.indentLevel++
fields := make([]string, 0, len(sourceVariant.PayloadTypes))
for i := range sourceVariant.PayloadTypes {
expr, err := g.mappingExpr(fmt.Sprintf("value.Value%d", i), sourceVariant.PayloadTypes[i], targetVariant.PayloadTypes[i], sourceEnum.Name+"::"+sourceVariant.Name)
expr, err := g.mappingExpr(fmt.Sprintf("value.Value%d", i), sourceVariant.PayloadTypes[i], targetVariant.PayloadTypes[i], sourceEnum.Name+"."+sourceVariant.Name)
if err != nil {
return err
}