Replace reflect.TypeOf with reflect.TypeFor#4311
Merged
StephenButtolph merged 1 commit intomasterfrom Sep 23, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes reflection usage by replacing reflect.TypeOf calls with the newer reflect.TypeFor generic function introduced in Go 1.22. This change improves type safety and readability by eliminating the need for pointer dereferencing patterns with nil values.
Key changes:
- Replace
reflect.TypeOf((*Type)(nil)).Elem()pattern withreflect.TypeFor[Type]() - Replace
reflect.TypeOf(&Type{})pattern withreflect.TypeFor[*Type]()
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
maru-ava
approved these changes
Sep 22, 2025
michaelkaplan13
approved these changes
Sep 23, 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.
Why this should be merged
This was suggested with #4211
How this works
Includes the prior diff + addresses my comment (for this test only file). I'm making a followup to fix the codec (which is non-trivial, so didn't want to mix it with this PR).
How this was tested
CI
Need to be documented in RELEASES.md?
no.