hash: use generic instantiation#1538
Merged
jonjohnsonjr merged 2 commits intogoogle:mainfrom Jan 24, 2023
Merged
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.
Collaborator
|
Oh that's wonderful. A few more places: |
Contributor
Author
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. |
jonjohnsonjr
approved these changes
Jan 24, 2023
imjasonh
reviewed
Jan 25, 2023
| func sha256String(s string) string { | ||
| h := sha256.Sum256([]byte(s)) | ||
| return hex.EncodeToString(h[:]) | ||
| h, _, _ := v1.SHA256(bytes.NewReader([]byte(s))) |
Contributor
There was a problem hiding this comment.
strings.NewReader could be better here
Contributor
|
We might want a lint check that |
jonjohnsonjr
pushed a commit
to jonjohnsonjr/go-containerregistry
that referenced
this pull request
Jan 25, 2023
* 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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