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
In proto files, don't allow customname which renames Id to ID.
Rationale
In our proto files, we sometimes use gogoproto's customname tag to rename fields, e.g. ClientId to ClientID, to fit what the Go linter recommends. In the generated *.pb.go files, we indeed see fields with ...ID (capitalized).
In #6918, we are adding grpc-gateway, who generates other files *.pb.gw.go. However, grpc-gateway ignores gogoproto's customname tag, and outputs fields with ...Id (PascalCase). See here for an example.
The Go compiler then obviously complains.
Potential solutions
Create a PR on grpc-gateway, to make them take into account gogoproto.
Add some plugins/hacks in our ./scripts to manually change Id->ID inside grpc-gateway-generated files *.pb.gw.go.
You're still free to use ...ID in variable names and elsewhere in the code, so it might create some small inconsistencies in namings.
We don't remove all customnames (e.g. Ed25519->ED25519, Url->URL are kept). When generating grpc-gateway files, they didn't seem to interfere. For now we only change ID->Id, as these were the ones that made the compiler shout. But there might be some more in the future.
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate contributors tagged
Contributor assigned/self-assigned
The text was updated successfully, but these errors were encountered:
Summary
In proto files, don't allow
customname
which renamesId
toID
.Rationale
In our proto files, we sometimes use gogoproto's
customname
tag to rename fields, e.g.ClientId
toClientID
, to fit what the Go linter recommends. In the generated*.pb.go
files, we indeed see fields with...ID
(capitalized).In #6918, we are adding grpc-gateway, who generates other files
*.pb.gw.go
. However, grpc-gateway ignores gogoproto'scustomname
tag, and outputs fields with...Id
(PascalCase). See here for an example.The Go compiler then obviously complains.
Potential solutions
./scripts
to manually changeId
->ID
inside grpc-gateway-generated files*.pb.gw.go
.customname
on Id renaming.#7032 implements 3.
Notes
...ID
in variable names and elsewhere in the code, so it might create some small inconsistencies in namings.customnames
(e.g.Ed25519->ED25519
,Url->URL
are kept). When generating grpc-gateway files, they didn't seem to interfere. For now we only changeID->Id
, as these were the ones that made the compiler shout. But there might be some more in the future.For Admin Use
The text was updated successfully, but these errors were encountered: