You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The official Protobuf guide is pretty clear that field names should be lower snake case. But Amino currently outputs the existing Go struct field names which are not snake case. For us, this results in many Protobuf linter warnings like:
Field name "PackagePath" should be lower_snake_case, such as "package_path".
Having so many linter warnings makes it difficult to find important warnings that we need to fix. Therefore, it is desirable for Amino to be able to use lower snake case for field names.
If you agree that it is desirable for Amino to be able to output lower snake case, there are a few options:
Change Amino to always use ToLowerSnakeCase(field.Name) as shown above. (Easiest for devs.)
Add an option to genproto.WriteProto3Schema to optionally output lower snake case. (Allows backwards compatibility, if that is important.)
Amino already extracts the JSON string from Go code like PackagePath string `json:"package_path"` We could make Amino extract a proto string and use it if it is present, like PackagePath string `json:"package_path" proto:"package_path"` (Uses existing mechanisms. Backwards compatible. But lots of work for the dev writing the Go struct.)
Any of these solutions is a trivial amount of code. We could do a quick pull request. What do you think?
The text was updated successfully, but these errors were encountered:
The official Protobuf guide is pretty clear that field names should be lower snake case. But Amino currently outputs the existing Go struct field names which are not snake case. For us, this results in many Protobuf linter warnings like:
Having so many linter warnings makes it difficult to find important warnings that we need to fix. Therefore, it is desirable for Amino to be able to use lower snake case for field names.
For option 1 below, the Amino code to output the Protobuf field name can be changed from:
to
where we can borrow
ToLowerSnakeCase
from the official buf code.If you agree that it is desirable for Amino to be able to output lower snake case, there are a few options:
ToLowerSnakeCase(field.Name)
as shown above. (Easiest for devs.)genproto.WriteProto3Schema
to optionally output lower snake case. (Allows backwards compatibility, if that is important.)PackagePath string `json:"package_path"`
We could make Amino extract a proto string and use it if it is present, likePackagePath string `json:"package_path" proto:"package_path"`
(Uses existing mechanisms. Backwards compatible. But lots of work for the dev writing the Go struct.)Any of these solutions is a trivial amount of code. We could do a quick pull request. What do you think?
The text was updated successfully, but these errors were encountered: