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
typeStarListRequeststruct {
state protoimpl.MessageStatesizeCache protoimpl.SizeCacheunknownFields protoimpl.UnknownFieldsPageint64`protobuf:"varint,1,opt,name=Page,proto3" json:"Page,omitempty"`Limitint64`protobuf:"varint,2,opt,name=Limit,proto3" json:"Limit,omitempty"`Keyword*string`protobuf:"bytes,3,opt,name=Keyword,proto3,oneof" json:"Keyword,omitempty"`
}
See? It's a pointer. If api's generation of this field is not a pointer, it will be a trouble in api logic. since you have to do a if judgement to conver the filed to a pointer before you call rpc server.
The error is
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environments (please complete the following information):
OS: [e.g. Linux]
go-zero version [e.g. 1.2.1]
goctl version [e.g. 1.2.1, optional]
More description
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Tony7817
changed the title
Why optional request parameter is not a pointer after generating using goctl
Why optional request parameter is not a pointer type generated by goctl
Oct 22, 2024
Tony7817
changed the title
Why optional request parameter is not a pointer type generated by goctl
Why optional request parameter is not a pointer type generated by goctl api
Oct 22, 2024
Describe the bug
one block of my api is defined as:
The keyword is optional. When I generate my code with goctl. The types.go is shown as blow:
Why the Keyword is not a pointer since it's optional?
Let's see the protobuf's generation:
The code generated:
See? It's a pointer. If api's generation of this field is not a pointer, it will be a trouble in api logic. since you have to do a if judgement to conver the filed to a pointer before you call rpc server.
The error is
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environments (please complete the following information):
More description
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: