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

feat: allow struct slice and struct array for valueType #70

Merged
merged 2 commits into from
Feb 3, 2024

Conversation

cia-rana
Copy link
Contributor

@cia-rana cia-rana commented Feb 2, 2024

Description

Allow struct slices and struct arrays for valueType (including Header and enc.EncodeHeader). However, this does not apply to two-dimensional arrays, etc.

Fixes #69

Checklist

  • Code compiles without errors
  • Added new tests for the provided functionality
  • All tests are passing
  • Updated the README and/or documentation, if necessary

@jszwec
Copy link
Owner

jszwec commented Feb 2, 2024

that's not what we agreed to. We agreed that enc.EncodeHeader would understand a slice argument so you could encode it youself.

Your change breaks the backward compatibility which is unacceptable

@jszwec jszwec self-requested a review February 2, 2024 17:30
@cia-rana
Copy link
Contributor Author

cia-rana commented Feb 2, 2024

Does func valueType inside enc.EncodeHeader cause an error for non-structs?

playground:
https://go.dev/play/p/2vzukSAf11V

@cia-rana
Copy link
Contributor Author

cia-rana commented Feb 2, 2024

Do you agree with reimplementing enc.EncodeHeader to recognize slice?

@jszwec
Copy link
Owner

jszwec commented Feb 2, 2024

Yea, that's what we discussed in the issue

@cia-rana
Copy link
Contributor Author

cia-rana commented Feb 2, 2024

I updated at 6a7ba1b.
Let me know if need to add test cases or update the documentation.

@cia-rana cia-rana changed the title feat: write header if array is empty feat: allow struct slice and struct array for valueType Feb 2, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4c3b8e6) 97.50% compared to head (6a7ba1b) 97.50%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #70   +/-   ##
=======================================
  Coverage   97.50%   97.50%           
=======================================
  Files           8        8           
  Lines        1040     1044    +4     
=======================================
+ Hits         1014     1018    +4     
  Misses         16       16           
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jszwec
Copy link
Owner

jszwec commented Feb 3, 2024

LGTM

@jszwec jszwec merged commit 53deda7 into jszwec:master Feb 3, 2024
7 checks passed
@cia-rana cia-rana deleted the issue-69 branch February 4, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support writing the header if a slice is empty
3 participants