forked from darccio/mergo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use src map if dst is nil and can't be set
see darccio#90 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/imdario/mergo | ||
module github.com/ndeloof/mergo | ||
|
||
go 1.13 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package mergo | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
type structWithMap struct { | ||
Data map[string]string | ||
} | ||
|
||
|
||
func TestIssue90(t *testing.T) { | ||
dst := map[string]structWithMap{ | ||
"struct": { | ||
Data: nil, | ||
}, | ||
} | ||
src := map[string]structWithMap{ | ||
"struct": { | ||
Data: map[string]string{ | ||
"foo": "bar", | ||
}, | ||
}, | ||
} | ||
expected := map[string]structWithMap{ | ||
"struct": { | ||
Data: map[string]string{ | ||
"foo": "bar", | ||
}, | ||
}, | ||
} | ||
|
||
err := Merge(&dst, src, WithOverride) | ||
if err != nil { | ||
t.Errorf("unexpected error %v", err) | ||
} | ||
|
||
if !reflect.DeepEqual(dst, expected) { | ||
t.Errorf("expected: %#v\ngot: %#v", expected, dst) | ||
} | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ndeloof
Author
Owner
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Missing newline at end of file"