Feature request: generate enums
Hi,
I've noticed that the enums are not being generated in the schema. Is it possible to enable the generation of enums?
Thank you
Can you give an example of what you would expect it to generate?
hi @nrwiersma thanks for prompt reply
So with gogen-avro any schema with an enum is gonna be generated like so:
{
"name": "status",
"type": {
"name": "status",
"type": "enum",
"symbols": [
"undefined",
"pending",
"confirmed",
"failed"
]
}
}
type Status int32
const (
StatusUndefined Status = 0
StatusPending Status = 1
StatusConfirmed Status = 2
StatusFailed Status = 3
)
func (e Status) String() string {
switch e {
case StatusUndefined:
return "undefined"
case StatusPending:
return "pending"
case StatusConfirmed:
return "confirmed"
case StatusFailed:
return "failed"
}
return "unknown"
}
The approach taken to generate the enum is not important to me. It could be like the example above or a group of string constants. The important thing is to have access to the values in the generated code without requiring me to search through the Avro schema.
Thanks Eduardo
hi @nrwiersma
I'm happy to-do this work if it's ok
I just need some guidelines for what do we want
Hey. You are welcome to take a crack at it. Your proposed typed enum is good with me, but you need to consider that using the name directly is likely to cause conflicts, so making it unique is going to be the challenge.