-
Notifications
You must be signed in to change notification settings - Fork 276
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
Add support for arrays #564
Conversation
Don't recall. Can you add a test? |
Do we have tests for the encoding part of the library? I can't find them. |
|
Found it! I also implement the decoding! |
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.
I think the encode and decode functions can be the same for both slice and array and the type switch can be merged to case reflect.Slice, reflect.Array:
to make it obvious. Maybe rename the functions to writeSliceOrArray
and similar. The tests will ensure that it works.
Keep error messages consistent and return the upper bound.
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.
After looking at #566 which merges the functions it became clear that this approach doesn't increase readability. There are too many subtle differences. So we go with separate functions for encoding slices and arrays.
I've found a fast path for byte arrays, updated the tests and made the error messages consistent.
LGTM now
Any reason why this was not implemented?
We have a use case with static size array, and it was returning an error.