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

Optional field with json tag "omitempty" should be type of pointer. #159

Open
nvthongswansea opened this issue Nov 3, 2020 · 0 comments
Labels
breaking-change A change that needs a major version bump
Milestone

Comments

@nvthongswansea
Copy link
Member

nvthongswansea commented Nov 3, 2020

Optional field with json tag "omitempty" should be type of pointer, since the optional fields usually accepts 3 types of input: nil (omitted when the field is nil), empty (Should not be omitted. eg: "" for string, 0 for int), and not empty. E.g:
Labels []string json:"labels,omitempty"

should be

Labels *[]string json:"labels,omitempty"

@nvthongswansea nvthongswansea added this to the v4 milestone Nov 3, 2020
@bkircher bkircher added the breaking-change A change that needs a major version bump label Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change A change that needs a major version bump
Projects
None yet
Development

No branches or pull requests

2 participants