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
Cut Your Data Warehouse Bill by 54% Icon
Cut Your Data Warehouse Bill by 54%

Migrate from Snowflake, Redshift, or Databricks with free tools. No SQL rewrites.

BigQuery delivers 54% lower TCO with serverless scale and flexible pricing. Free migration tools handle the SQL translation automatically.
Try 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