Skip to content

Conversation

@bep
Copy link
Member

@bep bep commented Oct 23, 2025

  • Use helper funcs in hreflect package when possible.
  • Use hreflect.ConvertIfPossible to handle conversions when possible.

@bep bep force-pushed the feat/cleanupreflectoc25 branch from 75842f6 to c0ed3a3 Compare October 23, 2025 14:41
@bep bep requested a review from Copilot October 23, 2025 15:16
Copy link

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 refactors the tpl/collections package to simplify reflection usage by consolidating helper functions into the hreflect package. The main goals are to reduce code duplication and provide a centralized, well-tested implementation of type conversion utilities.

Key changes include:

  • Removing local reflection helper functions (toFloat, toInt, toUint, toString, isNumber, etc.) from tpl/collections
  • Implementing a comprehensive ConvertIfPossible function in hreflect that handles lossless numeric conversions with proper overflow and precision checks
  • Adding new conversion helper functions (ToInt64E, ToFloat64E, ToStringE) to hreflect

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tpl/collections/where.go Replaces local helper functions with hreflect equivalents for type checking and conversion
tpl/collections/where_test.go Removes TestToFloat test now covered by hreflect tests
tpl/collections/reflect_helpers.go Removes duplicate helper functions (numberToFloat, convertNumber, isNumber, etc.) in favor of hreflect package
tpl/collections/collections.go Updates to use hreflect conversion functions and fixes type vs kind confusion in Union
tpl/collections/symdiff_test.go Removes extraneous blank line
common/hreflect/helpers.go Implements comprehensive ConvertIfPossible with overflow/precision checking for int, uint, and float conversions
common/hreflect/convert.go Adds new conversion helper functions with both error-returning and panicking variants
common/hreflect/helpers_test.go Expands test coverage for ConvertIfPossible with additional conversion scenarios
common/hreflect/convert_test.go Adds basic tests and benchmarks for new conversion functions
htesting/hqt/checkers.go Adds IsSameNumber checker supporting all numeric types for testing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bep bep force-pushed the feat/cleanupreflectoc25 branch from c0ed3a3 to 8f73140 Compare October 23, 2025 15:33
@bep bep requested a review from Copilot October 23, 2025 16:20
Copy link

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bep bep force-pushed the feat/cleanupreflectoc25 branch 9 times, most recently from f4783af to ecf5011 Compare October 26, 2025 15:37
@bep bep requested a review from Copilot October 26, 2025 16:12
Copy link

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

Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bep bep force-pushed the feat/cleanupreflectoc25 branch from dadf23e to ba188d3 Compare October 26, 2025 16:17
* Use helper funcs in hreflect package when possible.
* Use hreflect.ConvertIfPossible to handle conversions when possible.
* Move scratch.go from common/maps to common/hstore to clear cyclic import in the next step.
* Move Indirect to hreflect and reimplementing it and adusting the behavior to preserve struct pointers.
* Adjust evaluateSubElem used by where and others making the struct pointer method case slightly faster.
@bep bep force-pushed the feat/cleanupreflectoc25 branch from ba188d3 to f7317df Compare October 26, 2025 16:36
@bep bep merged commit 3893e70 into gohugoio:master Oct 26, 2025
6 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.

1 participant