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

Feature request: xxxtags (moretags for XXX_* fields) #647

Open
oceanful opened this issue Dec 4, 2019 · 2 comments · May be fixed by #746
Open

Feature request: xxxtags (moretags for XXX_* fields) #647

oceanful opened this issue Dec 4, 2019 · 2 comments · May be fixed by #746

Comments

@oceanful
Copy link

oceanful commented Dec 4, 2019

As requested in https://groups.google.com/forum/#!topic/gogoprotobuf/xmFnqAS6MIc

it would very useful to be able to set struct tags on the XXX_* fields, so that they can be ignored when used for other serialization formats. (For example, the json:"_" struct tag is already added to those fields by default.)

type Station struct {
	AlignmentId          string   `protobuf:"bytes,1,opt,name=alignment_id,json=alignmentId,proto3" json:"alignment_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Would it be possible to have a message-level option called xxxtags, and a file-level analog xxxtags_all?

message Station {
  option (gogoproto.xxxtags) = "firestore:\"-\"";

  string alignment_id = 1;
};

to generate:

type Station struct {
	AlignmentId          string   `protobuf:"bytes,1,opt,name=alignment_id,json=alignmentId,proto3" json:"alignment_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-" firestore:"-"`
	XXX_sizecache        int32    `json:"-" firestore:"-"`
}
@ivybridge-3c33
Copy link

how to ?

@oceanful
Copy link
Author

Hmm ... one way could be to do something like what is done for moretags

gogoMoreTags := gogoproto.GetMoreTags(field)
)

in the generateInternalStructFields() method.

func (g *Generator) generateInternalStructFields(mc *msgCtx, topLevelFields []topLevelField) {
)

But I haven't studied the code in depth; there may be a better way!

@MangioneAndrea MangioneAndrea linked a pull request Jan 16, 2022 that will close this issue
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.

2 participants