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
{{ message }}
Repository navigation
Add support for custom struct tags like custom:"name" #234
typeMyTypestruct {
state protoimpl.MessageStatesizeCache protoimpl.SizeCacheunknownFields protoimpl.UnknownFieldsIdstring`protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`Namestring`protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`CreateTime*timestamppb.Timestamp `protobuf:"bytes,3,opt,name=create_time,json=createTime,proto3" json:"
}
func (x *MyType) GetId() string {
if x != nil {
return x.Id
}
return ""
}
/* other generated functions for exported fields */
The above struct results in both the non-exported fields and duplicate methods being made available to the expression context. It also means that the default names in the expression (prior to patching) don't match the names given in the protobuf.
Activity
antonmedv commentedon Apr 27, 2022
Make sense. I'll add it to my todo list :)
antonmedv commentedon Nov 5, 2022
Done!
NickYadance commentedon Sep 4, 2025
Similar issue but failed to find workaround. So is there any way to refer field by json tag in expr for this protobuf case ?
[-]Enhance expr.Env() options on structs[/-][+]Add support for custom struct tags like `custom:"name"`[/+]