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
encoding/binary: document that ByteOrder must be non-nil #64386
Comments
This does not need to go through the proposal process, feel free to send a CL. |
I'd say it should panic on nil ByteOrder for consistency |
The current documentation says: “Bytes read from
In my experience, it is pretty much always a mistake for documentation to promise to panic if an invalid argument is used, because that prevents future changes that give defined behavior to previously-invalid arguments. If anything, perhaps we should clarify as: “… decoded using the specified byte order, which must be non-nil, and written …”. |
I agree with @bcmills - I would prefer |
Under-enforcing is also not good since there will be people depending on the undefined behaviour which creates friction for any kind of change in both directions. |
Adding nil check for int8 case impacts performance by -10% |
Proposal Details
this panics as expected:
but this does not:
I think the docs should reflect that
ByteOrder
can benil
if the integer width is one byte.https://godocs.io/encoding/binary#Read
The text was updated successfully, but these errors were encountered: