-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
New Reader convenience methods for reading into {int, uint8, uint16, uint32} without caller type conversion. #3
Conversation
uint8, uint16, uint32} without caller type conversion.
Codecov Report
@@ Coverage Diff @@
## master #3 +/- ##
===========================================
- Coverage 100% 83.24% -16.76%
===========================================
Files 2 2
Lines 149 179 +30
===========================================
Hits 149 149
- Misses 0 30 +30
Continue to review full report at Codecov.
|
Size of I see the uses of Also if we're adding varying sizes for reads, why not do the same for writes? Therefore I tend not to include this PR. |
How about limiting
Yes, that's feasible. Please LMK if you're open to this in an amended PR.
There is less incentive to do so for writes, as it's very easy to typecast to The problem with the
Of course they can; but it is significantly more convenient for these methods to be built into the package: the user doesn't have to write them over-and-over, whenever they use the package. In my case, I use |
The thing is there are also signed types, e.g. Adding all signed and unsigned variants would bloat the API. So I propose an alternative: Add a new field to
Now you can do a one-liner just like with
This way you don't have to add all variants, and you can even defer error checking, reading all the fields you need and just check error once. If you like this and would satisfy you, I'd rather implement this. |
Great idea! That would significantly reduce boilerplate even further. I would only suggest we refine the naming. Where the Go standard library uses the word "Must", it usually accompanies a
In this case, please consider using a softer name like: |
You're right on the naming conventions, it was just a quick idea, not yet refined.
|
I also wish to remove |
OK, it's done. I added |
Amazing work. Thank you for taking the time on this issue and your efforts over the past couple of years maintaining
I like it -- simplifies it further.
Excellent! I also like how |
These methods significantly simplified my code, when parsing a bitstream into a struct.
It extends the API, and does not modify existing method signatures.