Skip to content

Add hash.Clone interface for HMAC and Hash#94

Merged
mertakman merged 3 commits intomainfrom
add-hashclone-method
Jun 13, 2025
Merged

Add hash.Clone interface for HMAC and Hash#94
mertakman merged 3 commits intomainfrom
add-hashclone-method

Conversation

@mertakman
Copy link
Contributor

This PR implements upcoming hash.Clone interface on HMAC and hashes for keeping hash.Hash returns compatible with Go 1.25.

@mertakman mertakman requested review from Copilot and dagood June 12, 2025 00:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.Cloner under a build tag
  • Define a custom HashCloner interface (pre-1.25) and update hashX.Clone to match
  • Add TestHash_Clone and 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.Cloner interface in Go 1.25, so readers immediately understand the purpose of this type alias.
type HashCloner = hash.Cloner

@mertakman mertakman requested review from gdams and qmuntal June 12, 2025 00:59
Copy link
Member

@qmuntal qmuntal left a comment

Choose a reason for hiding this comment

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

LGTM minus one comment!

@mertakman mertakman merged commit b7cc686 into main Jun 13, 2025
19 checks passed
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.

4 participants