Ecosyste.ms: Repos
An open API service providing repository metadata for many open source software ecosystems.
Package Usage: go: github.com/imdario/mergo
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).
It is ready for production use. It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, etc.
Please keep in mind that a problematic PR broke 0.3.9. We reverted it in 0.3.10. We consider 0.3.10 as stable but not bug-free. . Also, this version adds suppot for go modules.
Keep in mind that in 0.3.2, Mergo changed Merge() and Map() signatures to support transformers. We added an optional/variadic argument so that it won't break the existing code.
If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with go get -u github.com/imdario/mergo. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
Do your usual installation procedure:
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. Also, maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
Also, you can merge overwriting values using the transformer WithOverride.
Additionally, you can map a map[string]interface{} to a struct (and otherwise, from struct to map), following the same restrictions as in Merge(). Keys are capitalized to find each corresponding exported field.
Warning: if you map a struct to map, it won't do it recursively. Don't expect Mergo to map struct members of your struct as map[string]interface{}. They will be just assigned as values.
Here is a nice example:
Transformers allow to merge specific types differently than in the default behavior. In other words, now you can customize how some types are merged. For example, time.Time is a struct; it doesn't have zero value but IsZero can return true because it has fields with zero value. How can we merge a non-zero time.Time?
If I can help you, you have an idea or you are using Mergo in your projects, don't hesitate to drop me a line (or a pull request): https://twitter.com/im_dario
Written by Dario Castañé: https://da.rio.hn
BSD 3-Clause license, as Go language.
15 versions
Latest release: 11 months ago
29,734 dependent packages
View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/imdario/mergo
View more repository details: https://repos.ecosyste.ms/hosts/GitHub/repositories/darccio%2Fmergo
Dependent Repos 61,876
admariner/jitsu Fork of jitsucom/jitsu
Jitsu is an open-source data integration platform- v0.3.5 configurator/backend/go.sum
- v0.3.8 configurator/backend/go.sum
- v0.3.10 configurator/backend/go.sum
- v0.3.11 configurator/backend/go.sum
- v0.3.5 server/go.sum
- v0.3.8 server/go.sum
- v0.3.10 server/go.sum
- v0.3.11 server/go.sum
Size: 29.4 MB - Last synced: about 2 months ago - Pushed: 10 months ago
kmodules/resource-metadata
API for defining metadata about Kubernetes resources- v0.3.13 go.mod
- v0.3.5 go.sum
- v0.3.13 go.sum
Size: 75.5 MB - Last synced: 8 days ago - Pushed: 9 days ago
ossf/scorecard-action
Official GitHub Action for OpenSSF Scorecard.- v0.3.12 go.mod
- v0.3.4 go.sum
- v0.3.5 go.sum
- v0.3.8 go.sum
- v0.3.9 go.sum
- v0.3.10 go.sum
- v0.3.11 go.sum
- v0.3.12 go.sum
Size: 6.39 MB - Last synced: 2 days ago - Pushed: 3 days ago
zeromike/syft Fork of anchore/syft
CLI tool and library for generating a Software Bill of Materials from container images and filesystems- v0.3.12 go.mod
- v0.3.4 go.sum
- v0.3.5 go.sum
- v0.3.8 go.sum
- v0.3.9 go.sum
- v0.3.10 go.sum
- v0.3.11 go.sum
- v0.3.12 go.sum
Size: 10.4 MB - Last synced: 12 months ago - Pushed: almost 2 years ago
aberja/argo Fork of argoproj/argo-workflows
Argo Workflows: Get stuff done with Kubernetes.- v0.3.12 go.mod
- v0.3.5 go.sum
- v0.3.11 go.sum
- v0.3.12 go.sum
Size: 67.2 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
krasish/test-infra Fork of kyma-project/test-infra
Test infrastructure for the Kyma project.- v0.3.4 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.5 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.6 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.7 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.8 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.9 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.10 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.11 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.12 development/gcp/cloud-functions/getfailureinstancedetails/go.sum
- v0.3.4 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.5 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.6 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.7 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.8 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.9 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.10 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.11 development/kyma-ci-force-bot/ciforcebot/go.sum
- v0.3.5 development/prow-installer/go.sum
- v0.3.5 development/test-log-collector/go.sum
- v0.3.9 development/test-log-collector/go.sum
- v0.3.12 go.mod
- v0.3.4 go.sum
- v0.3.5 go.sum
- v0.3.6 go.sum
- v0.3.7 go.sum
- v0.3.8 go.sum
- v0.3.9 go.sum
- v0.3.12 go.sum
Size: 15.3 MB - Last synced: about 1 year ago - Pushed: about 1 year ago
spolti/kie-cloud-operator Fork of kiegroup/kie-cloud-operator
OCP Operator for KIE- v0.3.12 go.mod
- v0.3.7 go.sum
Size: 100 MB - Last synced: 8 months ago - Pushed: 8 months ago
dhis2-sre/im-inspector
- v0.3.12 go.mod
- v0.3.12 go.sum
Size: 281 KB - Last synced: 11 days ago - Pushed: 13 days ago
cheqd/tendermint Fork of tendermint/tendermint
⟁ Tendermint Core (BFT Consensus) in Go- v0.3.13 go.sum
Size: 142 MB - Last synced: 23 days ago - Pushed: about 1 year ago
alicefr/kubevirt Fork of kubevirt/kubevirt
Kubernetes Virtualization API and runtime in order to define and manage virtual machines.- v0.3.5 cluster-up/cluster/kind-k8s-sriov-1.17.0/csrcreator/go.sum
- v0.0.0-20171009183408-7fe0c75c13ab go.sum
- v0.3.5 go.sum
- v0.3.6 go.sum
- v0.3.7 go.sum
- v0.3.5 staging/src/kubevirt.io/client-go/examples/listvms/go.sum
- v0.0.0-20171009183408-7fe0c75c13ab staging/src/kubevirt.io/client-go/go.sum
- v0.3.5 staging/src/kubevirt.io/client-go/go.sum
- v0.3.7 staging/src/kubevirt.io/client-go/go.sum
Size: 255 MB - Last synced: 15 days ago - Pushed: 15 days ago
ryanlycch/go-zero-looklook Fork of Mikaelemmmm/go-zero-looklook
🔥基于go-zero(go zero) 微服务全技术栈开发最佳实践项目。Develop best practice projects based on the full technology stack of go zero (go zero) microservices.- v0.3.5 go.sum
Size: 101 MB - Last synced: 22 days ago - Pushed: 22 days ago
ahmedabu98/beam Fork of apache/beam
Apache Beam is a unified programming model for Batch and Streaming- v0.3.5 sdks/go.sum
- v0.3.8 sdks/go.sum
- v0.3.10 sdks/go.sum
- v0.3.11 sdks/go.sum
- v0.3.12 sdks/go.sum
Size: 365 MB - Last synced: 19 days ago - Pushed: 20 days ago
champ-oss/terraform-aws-metabase
- v0.3.5 test/src/go.sum
- v0.3.8 test/src/go.sum
- v0.3.10 test/src/go.sum
- v0.3.11 test/src/go.sum
Size: 229 KB - Last synced: 7 days ago - Pushed: 7 days ago
SammyEnigma/hardentools Fork of hardentools/hardentools
Hardentools simply reduces the attack surface on Microsoft Windows computers by disabling low-hanging fruit risky features.- v0.3.12 go.mod
- v0.3.9 go.sum
- v0.3.12 go.sum
Size: 3.34 MB - Last synced: 6 months ago - Pushed: 6 months ago
fahedouch/crossplane-runtime Fork of crossplane/crossplane-runtime
A set of libraries for writing Crossplane controllers.- v0.3.12 go.mod
- v0.3.5 go.sum
- v0.3.12 go.sum
Size: 2.37 MB - Last synced: 10 months ago - Pushed: 10 months ago
nakamasato/mysql-operator
Manage MySQL users, databases, schemas, etc.- v0.3.12 go.mod
- v0.3.5 go.sum
- v0.3.11 go.sum
- v0.3.12 go.sum
Size: 1.31 MB - Last synced: 1 day ago - Pushed: 2 days ago
Jimdo/terraform-provider-solaris
Terraform provider to provision static resources using the Solarisbank API.- v0.3.13 go.mod
- v0.3.11 go.sum
- v0.3.12 go.sum
- v0.3.13 go.sum
Size: 4.6 MB - Last synced: 6 days ago - Pushed: about 1 year ago
observIQ/grafana-agent Fork of grafana/agent
Telemetry agent for the LGTM stack.- v0.3.13 go.mod
- v0.3.5 go.sum
- v0.3.6 go.sum
Size: 48.3 MB - Last synced: 5 months ago - Pushed: 5 months ago