Skip to content

Conversation

@EduardoLaranjo
Copy link

@EduardoLaranjo EduardoLaranjo commented Apr 15, 2025

Goal of this PR

This PR tackles issue #428 by updating the avro generator to generate enums with the following format:

const (
	SPADES   Cards = "SPADES"
	HEARTS   Cards = "HEARTS"
	DIAMONDS Cards = "DIAMONDS"
	CLUBS    Cards = "CLUBS"
)

Instead of the just strings

How did I test it?

Regenerate the golden files

@nrwiersma
Copy link
Member

In order to get this reviewed, please fill in the PR description.

@EduardoLaranjo
Copy link
Author

Apologies @nrwiersma, I have update the PR description. I understand you are doing some refactor on generator, so this PR might not be needed, let me know.

Copy link
Member

@nrwiersma nrwiersma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change. I would be concerned that this will break some peoples code. IMO, it would be better to put it behind a flag/option to avoid this and maintain the status quo.

@EduardoLaranjo
Copy link
Author

EduardoLaranjo commented Apr 23, 2025

Nice change. I would be concerned that this will break some peoples code. IMO, it would be better to put it behind a flag/option to avoid this and maintain the status quo.

Yep I can make as an option. I was wondering if you have any idea to avoid name clashing.

I will also create a dedicated test for this feature

@nrwiersma
Copy link
Member

I was wondering if you have any idea to avoid name clashing.

Conventionally speaking, it gets prefixed with the type, which would be singular. Like this:

const (
	CardSpades   Card = "SPADES"
	CardHearts   Card = "HEARTS"
	CardDiamonds Card = "DIAMONDS"
	CardClubs    Card = "CLUBS"
)

@EduardoLaranjo
Copy link
Author

hi @nrwiersma I added the enum generation as optional and add one test

type Cards string

const (
SPADES Cards = "SPADES"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be all upper. It should also be prefixed with the type. So CardSpades.

"github.com/hamba/avro/v2"
)

type Cards string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be singular. It does not represent multiple cards, but a card.

@gdbi
Copy link

gdbi commented Aug 5, 2025

waiting for this to be merged .. thanks @nrwiersma

@nrwiersma
Copy link
Member

Waiting for the review to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants