Skip to content

Conversation

@hgiasac
Copy link
Collaborator

@hgiasac hgiasac commented Dec 13, 2025

This pull request introduces new equality checking methods for various environment variable wrapper types and adds comprehensive unit tests to ensure their correctness. The changes improve the ability to compare environment configuration values and references, covering both simple and map-based types.

The most important changes are:

Equality methods for environment value types:

  • Added Equal methods to EnvString, EnvInt, EnvBool, and EnvFloat types to allow comparison of both literal values and environment variable references. [1] [2] [3] [4]
  • Added an Equal method to the generic EnvAny type, using reflect.DeepEqual for value comparison.

Equality methods for map-based environment value types:

  • Added Equal methods to EnvMapString, EnvMapInt, EnvMapFloat, and EnvMapBool, utilizing the Go 1.21+ maps.Equal function for map value comparison. [1] [2] [3] [4]
  • Imported the maps package from the standard library to support map equality checks.

Unit testing:

  • Added comprehensive unit tests for all new Equal methods, covering a wide range of cases for each type, in the new files environment_equal_test.go and any_equal_test.go. [1] [2]

General improvements:

  • Imported reflect in any.go to support deep value comparison in the EnvAny.Equal method.

These changes collectively enhance the reliability and maintainability of code that deals with environment-based configuration by providing consistent equality logic and thorough test coverage.

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 pull request adds equality checking functionality to environment variable wrapper types in the goenvconf package. The implementation provides a consistent way to compare configuration values and their environment variable references across all supported types.

  • Introduces Equal methods for all environment value types (EnvString, EnvInt, EnvBool, EnvFloat, EnvAny)
  • Adds Equal methods for all map-based environment value types (EnvMapString, EnvMapInt, EnvMapFloat, EnvMapBool)
  • Provides comprehensive unit test coverage for all new equality methods

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
environment.go Adds Equal methods to EnvString, EnvInt, EnvBool, and EnvFloat types for comparing both literal values and environment variable references
map.go Adds Equal methods to EnvMapString, EnvMapInt, EnvMapFloat, and EnvMapBool types; imports maps package for map comparison
any.go Adds Equal method to EnvAny type using reflect.DeepEqual; imports reflect package
environment_equal_test.go Comprehensive test suite for Equal methods on basic environment types covering nil values, literals, variables, and mixed scenarios
map_equal_test.go Comprehensive test suite for Equal methods on map environment types including nil vs empty map edge cases
any_equal_test.go Comprehensive test suite for EnvAny.Equal covering various data types including strings, numbers, booleans, maps, and slices

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

@hgiasac hgiasac merged commit a333b36 into main Dec 13, 2025
1 check passed
@hgiasac hgiasac deleted the add-equal-methods branch December 13, 2025 02:48
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