Add hash.Clone interface for HMAC and Hash#94
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new HashCloner interface for both pre- and post-Go 1.25 environments and implements Clone on hashX so that CNG-backed hash instances remain compatible with the upcoming hash.Cloner in Go 1.25.
- Add Go 1.25–specific alias to
hash.Clonerunder a build tag - Define a custom
HashClonerinterface (pre-1.25) and updatehashX.Cloneto match - Add
TestHash_Cloneand a helper to validate the new clone behavior
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cng/hashclone_go125.go | Introduce HashCloner alias to hash.Cloner for Go 1.25+ builds |
| cng/hashclone.go | Define custom HashCloner interface with Clone() (HashCloner, error) |
| cng/hash.go | Update hashX.Clone signature and type assertion to use HashCloner |
| cng/hash_test.go | Add TestHash_Clone and writeToHash helper to exercise clone logic |
Comments suppressed due to low confidence (1)
cng/hashclone_go125.go:13
- [nitpick] Add a doc comment above this alias to explain that it bridges to the new
hash.Clonerinterface in Go 1.25, so readers immediately understand the purpose of this type alias.
type HashCloner = hash.Cloner
qmuntal
approved these changes
Jun 13, 2025
gdams
approved these changes
Jun 13, 2025
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 PR implements upcoming hash.Clone interface on HMAC and hashes for keeping hash.Hash returns compatible with Go 1.25.