Skip to content

Commit fb264ff

Browse files
committed
vendor: dario.cat/mergo v1.0.1
- fix: overwriteWithEmptyValue is forced to true when merging an object involving maps - fix: WithoutDereference should respect non-nil struct pointers full diff: darccio/mergo@v1.0.0...v1.0.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 986baf2 commit fb264ff

7 files changed

Lines changed: 65 additions & 52 deletions

File tree

vendor.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module github.com/docker/cli
77
go 1.21.0
88

99
require (
10-
dario.cat/mergo v1.0.0
10+
dario.cat/mergo v1.0.1
1111
github.com/containerd/platforms v0.2.1
1212
github.com/creack/pty v1.1.21
1313
github.com/distribution/reference v0.6.0

vendor.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
2-
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
1+
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
2+
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
33
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
44
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
55
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=

vendor/dario.cat/mergo/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# Output of the go coverage tool, specifically when used with LiteIDE
1414
*.out
1515

16+
# Golang/Intellij
17+
.idea
18+
1619
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
1720
.glide/
1821

vendor/dario.cat/mergo/README.md

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,21 @@ Also a lovely [comune](http://en.wikipedia.org/wiki/Mergo) (municipality) in the
4444

4545
## Status
4646

47-
It is ready for production use. [It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, Microsoft, etc](https://github.com/imdario/mergo#mergo-in-the-wild).
47+
Mergo is stable and frozen, ready for production. Check a short list of the projects using at large scale it [here](https://github.com/imdario/mergo#mergo-in-the-wild).
48+
49+
No new features are accepted. They will be considered for a future v2 that improves the implementation and fixes bugs for corner cases.
4850

4951
### Important notes
5052

5153
#### 1.0.0
5254

53-
In [1.0.0](//github.com/imdario/mergo/releases/tag/1.0.0) Mergo moves to a vanity URL `dario.cat/mergo`.
55+
In [1.0.0](//github.com/imdario/mergo/releases/tag/1.0.0) Mergo moves to a vanity URL `dario.cat/mergo`. No more v1 versions will be released.
56+
57+
If the vanity URL is causing issues in your project due to a dependency pulling Mergo - it isn't a direct dependency in your project - it is recommended to use [replace](https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive) to pin the version to the last one with the old import URL:
58+
59+
```
60+
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16
61+
```
5462

5563
#### 0.3.9
5664

@@ -64,55 +72,24 @@ If you were using Mergo before April 6th, 2015, please check your project works
6472

6573
If Mergo is useful to you, consider buying me a coffee, a beer, or making a monthly donation to allow me to keep building great free software. :heart_eyes:
6674

67-
<a href='https://ko-fi.com/B0B58839' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
6875
<a href="https://liberapay.com/dario/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
6976
<a href='https://github.com/sponsors/imdario' target='_blank'><img alt="Become my sponsor" src="https://img.shields.io/github/sponsors/imdario?style=for-the-badge" /></a>
7077

7178
### Mergo in the wild
7279

73-
- [moby/moby](https://github.com/moby/moby)
74-
- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
75-
- [vmware/dispatch](https://github.com/vmware/dispatch)
76-
- [Shopify/themekit](https://github.com/Shopify/themekit)
77-
- [imdario/zas](https://github.com/imdario/zas)
78-
- [matcornic/hermes](https://github.com/matcornic/hermes)
79-
- [OpenBazaar/openbazaar-go](https://github.com/OpenBazaar/openbazaar-go)
80-
- [kataras/iris](https://github.com/kataras/iris)
81-
- [michaelsauter/crane](https://github.com/michaelsauter/crane)
82-
- [go-task/task](https://github.com/go-task/task)
83-
- [sensu/uchiwa](https://github.com/sensu/uchiwa)
84-
- [ory/hydra](https://github.com/ory/hydra)
85-
- [sisatech/vcli](https://github.com/sisatech/vcli)
86-
- [dairycart/dairycart](https://github.com/dairycart/dairycart)
87-
- [projectcalico/felix](https://github.com/projectcalico/felix)
88-
- [resin-os/balena](https://github.com/resin-os/balena)
89-
- [go-kivik/kivik](https://github.com/go-kivik/kivik)
90-
- [Telefonica/govice](https://github.com/Telefonica/govice)
91-
- [supergiant/supergiant](supergiant/supergiant)
92-
- [SergeyTsalkov/brooce](https://github.com/SergeyTsalkov/brooce)
93-
- [soniah/dnsmadeeasy](https://github.com/soniah/dnsmadeeasy)
94-
- [ohsu-comp-bio/funnel](https://github.com/ohsu-comp-bio/funnel)
95-
- [EagerIO/Stout](https://github.com/EagerIO/Stout)
96-
- [lynndylanhurley/defsynth-api](https://github.com/lynndylanhurley/defsynth-api)
97-
- [russross/canvasassignments](https://github.com/russross/canvasassignments)
98-
- [rdegges/cryptly-api](https://github.com/rdegges/cryptly-api)
99-
- [casualjim/exeggutor](https://github.com/casualjim/exeggutor)
100-
- [divshot/gitling](https://github.com/divshot/gitling)
101-
- [RWJMurphy/gorl](https://github.com/RWJMurphy/gorl)
102-
- [andrerocker/deploy42](https://github.com/andrerocker/deploy42)
103-
- [elwinar/rambler](https://github.com/elwinar/rambler)
104-
- [tmaiaroto/gopartman](https://github.com/tmaiaroto/gopartman)
105-
- [jfbus/impressionist](https://github.com/jfbus/impressionist)
106-
- [Jmeyering/zealot](https://github.com/Jmeyering/zealot)
107-
- [godep-migrator/rigger-host](https://github.com/godep-migrator/rigger-host)
108-
- [Dronevery/MultiwaySwitch-Go](https://github.com/Dronevery/MultiwaySwitch-Go)
109-
- [thoas/picfit](https://github.com/thoas/picfit)
110-
- [mantasmatelis/whooplist-server](https://github.com/mantasmatelis/whooplist-server)
111-
- [jnuthong/item_search](https://github.com/jnuthong/item_search)
112-
- [bukalapak/snowboard](https://github.com/bukalapak/snowboard)
113-
- [containerssh/containerssh](https://github.com/containerssh/containerssh)
114-
- [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
115-
- [tjpnz/structbot](https://github.com/tjpnz/structbot)
80+
Mergo is used by [thousands](https://deps.dev/go/dario.cat%2Fmergo/v1.0.0/dependents) [of](https://deps.dev/go/github.com%2Fimdario%2Fmergo/v0.3.16/dependents) [projects](https://deps.dev/go/github.com%2Fimdario%2Fmergo/v0.3.12), including:
81+
82+
* [containerd/containerd](https://github.com/containerd/containerd)
83+
* [datadog/datadog-agent](https://github.com/datadog/datadog-agent)
84+
* [docker/cli/](https://github.com/docker/cli/)
85+
* [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
86+
* [go-micro/go-micro](https://github.com/go-micro/go-micro)
87+
* [grafana/loki](https://github.com/grafana/loki)
88+
* [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
89+
* [masterminds/sprig](github.com/Masterminds/sprig)
90+
* [moby/moby](https://github.com/moby/moby)
91+
* [slackhq/nebula](https://github.com/slackhq/nebula)
92+
* [volcano-sh/volcano](https://github.com/volcano-sh/volcano)
11693

11794
## Install
11895

@@ -141,6 +118,39 @@ if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
141118
}
142119
```
143120

121+
If you need to override pointers, so the source pointer's value is assigned to the destination's pointer, you must use `WithoutDereference`:
122+
123+
```go
124+
package main
125+
126+
import (
127+
"fmt"
128+
129+
"dario.cat/mergo"
130+
)
131+
132+
type Foo struct {
133+
A *string
134+
B int64
135+
}
136+
137+
func main() {
138+
first := "first"
139+
second := "second"
140+
src := Foo{
141+
A: &first,
142+
B: 2,
143+
}
144+
145+
dest := Foo{
146+
A: &second,
147+
B: 1,
148+
}
149+
150+
mergo.Merge(&dest, src, mergo.WithOverride, mergo.WithoutDereference)
151+
}
152+
```
153+
144154
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.
145155

146156
```go

vendor/dario.cat/mergo/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
5858
}
5959
fieldName := field.Name
6060
fieldName = changeInitialCase(fieldName, unicode.ToLower)
61-
if v, ok := dstMap[fieldName]; !ok || (isEmptyValue(reflect.ValueOf(v), !config.ShouldNotDereference) || overwrite) {
61+
if _, ok := dstMap[fieldName]; !ok || (!isEmptyValue(reflect.ValueOf(src.Field(i).Interface()), !config.ShouldNotDereference) && overwrite) || config.overwriteWithEmptyValue {
6262
dstMap[fieldName] = src.Field(i).Interface()
6363
}
6464
}

vendor/dario.cat/mergo/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
269269
if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
270270
return
271271
}
272-
} else {
272+
} else if src.Elem().Kind() != reflect.Struct {
273273
if overwriteWithEmptySrc || (overwrite && !src.IsNil()) || dst.IsNil() {
274274
dst.Set(src)
275275
}

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# dario.cat/mergo v1.0.0
1+
# dario.cat/mergo v1.0.1
22
## explicit; go 1.13
33
dario.cat/mergo
44
# github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24

0 commit comments

Comments
 (0)