Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avrogo generates non-idiomatic names #126

Open
ojcm opened this issue Nov 29, 2023 · 3 comments
Open

avrogo generates non-idiomatic names #126

ojcm opened this issue Nov 29, 2023 · 3 comments

Comments

@ojcm
Copy link

ojcm commented Nov 29, 2023

Names produced by avrogo do not follow idiomatic Go capitalisation/initialisation rules. (e.g. use ID rather than id or Id).

This can be reproduced with the following schema

{
    "name": "User",
    "type": "record",
    "fields": [
        {
            "name": "userID",
            "type": {
                "type": "string",
                "logicalType": "uuid"
            }
        }
    ]
}

avrogo generates

type User struct {
	Userid uuid.UUID `json:"userID"`
}

but an idiomatic representation would be

type User struct {
	UserID uuid.UUID `json:"userID"`
}

There are third-party libraries available to achieve this (e.g. github.com/hamba/avro uses github.com/ettle/strcase's PascalCase).

If this were implemented then it would be helpful to allow additional initialisms with command line arguments. For example in my use case I have schemas referring to MW (megawatts) and would like that initialised too.

I'm happy to work on this but I want to check if the change would be accepted before starting.

@skateinmars
Copy link
Member

Hello,

and thanks for the suggestion.

This is a reasonable request so please feel free to submit a PR
One thing that should be done though is preserve the current behavior to avoid breaking changes. Maybe a flag can be introduced to specify which case to use?

@ojcm
Copy link
Author

ojcm commented Jan 2, 2024

Hello, please could someone review the PR I opened?

@defgenx
Copy link

defgenx commented May 20, 2024

Hello @skateinmars. Do you think you would be able to review this PR please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants