-
Notifications
You must be signed in to change notification settings - Fork 559
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
hash: use generic instantiation #1538
hash: use generic instantiation #1538
Conversation
This enables doing something like opencontainers/go-digest#71 (comment) to override the hashing method (example: replace with sha256simd). When an importer does not overriden, the library should behave exactly the same.
Oh that's wonderful. A few more places:
|
Thanks, missed those ones! Updated a bit. Note the ignored errors match what the old function did internally so I think its safe |
Codecov Report
@@ Coverage Diff @@
## main #1538 +/- ##
==========================================
- Coverage 74.07% 73.27% -0.80%
==========================================
Files 112 117 +5
Lines 8385 9015 +630
==========================================
+ Hits 6211 6606 +395
- Misses 1570 1748 +178
- Partials 604 661 +57
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -47,8 +47,8 @@ const ( | |||
) | |||
|
|||
func sha256String(s string) string { | |||
h := sha256.Sum256([]byte(s)) | |||
return hex.EncodeToString(h[:]) | |||
h, _, _ := v1.SHA256(bytes.NewReader([]byte(s))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings.NewReader could be better here
We might want a lint check that |
* hash: use generic instantiation This enables doing something like opencontainers/go-digest#71 (comment) to override the hashing method (example: replace with sha256simd). When an importer does not overriden, the library should behave exactly the same. * catch a few more usages
This enables doing something like
opencontainers/go-digest#71 (comment) to override the hashing method (example: replace with sha256simd).
When an importer does not overriden, the library should behave exactly the same.
See #1330