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

DecodeHash fixes #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

DecodeHash fixes #24

wants to merge 2 commits into from

Conversation

scop
Copy link
Contributor

@scop scop commented Nov 13, 2023

See individual commits and their messages for details.

return nil, nil, nil, err
}

rest, err := ioutil.ReadAll(r)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ioutil is deprecated, could use io.ReadAll if we can assume Go 1.16+. The only info in the package I could locate about the supported version is 1.12 in go.mod.

Sscanf silently ignores it. Rewrite using a reader so we can make use of
the parse position to detect it.

The errors returned are not exactly the same for the same input as
before. In particular, scanf originated parse errors rather than
ErrInvalidHash are now returned for more inputs.

For completeness, includes tests for leading parameter junk, although
that was not a problem before either.

Could be somewhat faster and allocate less than the previous
implementation, too (no benchmarks run).
Return ErrInvalidHash on any.
@mitar
Copy link

mitar commented Dec 4, 2023

This looks great to me.

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.

None yet

2 participants