A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements. Mergo merges same-type structs and maps by setting default values in zero-value fields. Mergo won't merge unexported (private) fields. It will do recursively any exported one. It also won't merge structs inside maps (because they are not addressable using Go reflection). Also a lovely comune (municipality) in the Province of Ancona in the Italian region of Marche. Keep in mind that in 0.3.2, Mergo changed Merge()and Map() signatures to support transformers. I added an optional/variadic argument so that it won't break the existing code. You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. It won't merge empty structs value as they are zero values too.

Features

  • Recursive merging of structs and maps
  • Support for struct tags to control merging behavior
  • Support for custom merge functions for specific fields
  • Support for merging private fields
  • Support for merging anonymous fields
  • Support for merging maps with non-string keys

Project Samples

Project Activity

See All Activity >

Categories

Frameworks, Mapping

License

BSD License

Follow Mergo

Mergo Web Site

Other Useful Business Software
Powerful App Monitoring Without Surprise Bills Icon
Powerful App Monitoring Without Surprise Bills

AppSignal starts at $23/month with all features included. No overages, no hidden fees. 30-day free trial.

Tired of monitoring tools that punish you for scaling? AppSignal offers transparent, predictable pricing with every feature unlocked on every plan. Track errors, monitor performance, detect anomalies, and manage logs across Ruby, Python, Node.js, and more. Trusted by developers since 2012 with free dev-to-dev support. No credit card required to start your 30-day trial.
Try AppSignal Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Mergo!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Go

Related Categories

Go Frameworks, Go Mapping Software

Registered

2023-01-23