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

[Question] kratos generation pb file with omitempty tag #3427

Closed
yyfyfyang opened this issue Sep 24, 2024 · 3 comments
Closed

[Question] kratos generation pb file with omitempty tag #3427

yyfyfyang opened this issue Sep 24, 2024 · 3 comments
Labels
question Further information is requested

Comments

@yyfyfyang
Copy link

image

kratos proto client 生成的pb文件带有omitempty标签导致序列化的时候会忽略空值和默认值,怎么样可以在生成pb文件的时候不带这个标签

@yyfyfyang yyfyfyang added the question Further information is requested label Sep 24, 2024
@kratos-ci-bot
Copy link
Collaborator

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


image

The pb file generated by kratos proto client has the omitempty tag, which causes the null value and default value to be ignored during serialization. How can I generate the pb file without this tag?

@kratos-ci-bot kratos-ci-bot changed the title [Question] kratos生成的pb文件带有omitempty标签 [Question] kratos generation pb file with omitempty tag Sep 24, 2024
@shenqidebaozi
Copy link
Member

This has nothing to do with kratos, it is the default behavior after compiling with protoc-gen-go, and it should not be removed. `protojson supports keeping null values.

@shenqidebaozi
Copy link
Member

If you forcefully nested non proto structures outside the proto structure yourself, please refer to #1952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants