A Go library for merging structs and maps, useful for configuration defaults and avoiding complex conditionals.
Mergo is a Go library for merging same-type structs and maps. It simplifies setting default values in zero-value fields and is particularly useful for configuration management, eliminating the need for messy if-statements.
Go developers working on projects that require configuration management, such as CLI tools, microservices, or applications with complex struct initialization.
Developers choose Mergo for its stable, production-ready API with recursive merging, map-to-struct conversion, and customizable transformers, making it a reliable utility for handling struct and map merging without introducing unnecessary complexity.
Mergo: merging Go structs and maps since 2013
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Merges all exported fields recursively, eliminating nested if-statements for configuration setup, as explicitly stated in the README.
Supports bidirectional conversion between maps and structs with automatic key capitalization, useful for parsing configuration files, as demonstrated in the Map function examples.
Allows transformers to define custom merging for specific types like time.Time, handling edge cases where default behavior fails, with examples provided in the README.
Widely used in major projects like Docker and Kubernetes, with a stable API and no breaking changes planned, ensuring long-term reliability as highlighted in the status section.
Relies on Go reflection for merging, which can be slower than direct code and may not suit performance-critical paths, a common trade-off in such libraries.
Cannot merge private fields or structs inside maps, as admitted in the README, restricting use in scenarios with complex internal structures.
No new features are accepted and the library is considered stable but frozen, meaning bugs in corner cases might not be addressed promptly, as noted in the status.