We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
User { Links []string `json:"links,default="` }
This is a API file. How to set the default value of this slice to a null pointer? I tried setting it to nil but it didn't work.
The text was updated successfully, but these errors were encountered:
If you want to set the field value to null when there are no links in the JSON payload.
Please try to use a pointer as shown below:
User { Links *[]string `json:"links,optional"` }
reference: https://go-zero.dev/en/docs/tutorials/api/parameter
Sorry, something went wrong.
I tried it but got an error. Error: user.api line 84:22 mismatched input '[' expecting ID
Error: user.api line 84:22 mismatched input '[' expecting ID
It's valid to write it this way.
User { Links []string `json:"links,optional"` }
Sorry, it seems that api file doesn't support pointer type of slice data. Why you want a null pointer value not a empty slice?
This issue is stale because it has been open for 30 days with no activity.
No branches or pull requests
This is a API file. How to set the default value of this slice to a null pointer?
I tried setting it to nil but it didn't work.
The text was updated successfully, but these errors were encountered: