Let's say I've got a Player
defined in my .proto
file.
message Player {
string first_name = 1;
string last_name = 2;
int32 user_id = 3;
}
I'm using https://github.com/twitchtv/twirp to communicate between my Go backend and my JavaScript frontend. If you don't know Twirp it's simply JSON RPC over HTTP 1.1.
The Player
message is converted into a Go struct
type Player struct {
FirstName string
LastName string
UserId int32
}
As we all know uppercase fields are public. However I'd like to keep the UserId
private, i.e. make it lowercase. My users in the frontend should not be able to see the UserId
of a player. In my backend I need this information so I cannot simply remove the field.
Any ideas how to handle such a situation? Is it possible to have private fields in my .proto
files?