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

Add support for arrays #564

Merged
merged 7 commits into from
Mar 14, 2022
Merged

Add support for arrays #564

merged 7 commits into from
Mar 14, 2022

Conversation

siscia
Copy link
Contributor

@siscia siscia commented Mar 8, 2022

Any reason why this was not implemented?

We have a use case with static size array, and it was returning an error.

@magiconair
Copy link
Member

Don't recall. Can you add a test?

@siscia
Copy link
Contributor Author

siscia commented Mar 8, 2022

Do we have tests for the encoding part of the library?

I can't find them.

@magiconair
Copy link
Member

magiconair commented Mar 8, 2022

ua/decode_test.go it does both

@siscia
Copy link
Contributor Author

siscia commented Mar 8, 2022

Found it!

I also implement the decoding!

Copy link
Member

@magiconair magiconair left a 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.

Copy link
Member

@magiconair magiconair left a 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

@magiconair magiconair mentioned this pull request Mar 14, 2022
@magiconair magiconair added this to the v0.3.2 milestone Mar 14, 2022
@magiconair magiconair changed the title implements write arrays Add support for arrays Mar 14, 2022
@magiconair magiconair merged commit bda1dc9 into gopcua:main Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants