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

field name contains a number #2868

Open
zdevwu opened this issue Apr 4, 2024 · 1 comment
Open

field name contains a number #2868

zdevwu opened this issue Apr 4, 2024 · 1 comment

Comments

@zdevwu
Copy link

zdevwu commented Apr 4, 2024

Hi,

I don't see the rule for field name contains a number being enforce when using the DEFAULT lint configuration. The rule is mentioned in https://protobuf.dev/programming-guides/style/

If your field name contains a number, the number should appear after the letter instead of after the underscore. For example, use song_name1 instead of song_name_1

When field name like song_name_1 or song_1_name is used, there is no obvious problem when generating javascript and java code, but it is strange that only golang decides to keep the underscore. So the golang code looks like:

if msg.GetSongName_1() == "new song" {
  ...
}
if msg.GetSong_1Name() == "new song" {
  ...
}

I can't find an option to turn on the linter to spot the problem, is there any?

@zdevwu
Copy link
Author

zdevwu commented Apr 5, 2024

I noticed the commend in here:

	// We allow both effectively by not passing the option
	//return stringutil.ToLowerSnakeCase(s, stringutil.SnakeCaseWithNewWordOnDigits())

would an option be introduced to enforce the rule defined in the style guide?

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

No branches or pull requests

1 participant