-
Notifications
You must be signed in to change notification settings - Fork 156
feat(args): add support for empty slice un/marshahaling #692
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
Conversation
a865fc0 to
4a0a64b
Compare
internal/args/unmarshal.go
Outdated
| } | ||
|
|
||
| // Make sure index is a positive integer. | ||
| // We check if argNameWords[0] is an positive integer to handle cases like keys.0.value=12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a positive*
internal/args/marshal_test.go
Outdated
| StringsPtr: []*string{}, | ||
| }, | ||
| expected: []string{ | ||
| "strings=none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to support this for non-pointer slices? This is equivalent to not writing the argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not extactly the same
absent => []string(nil)
=none => []string{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK we don't have any use case for this as we always handle []string(nil) == []string{} in our APIs
internal/args/unmarshal.go
Outdated
| // If type is a slice: | ||
| // We check if argNameWords[0] is an number to handle cases like keys.0.value=12 | ||
|
|
||
| // We handle special case where array=none creates an empty slice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: When array=none, creates an empty slice.
cea05ee to
b67553d
Compare
kindermoumoute
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.