Comments (6)
It should be fixed now.
from mergo.
If I use Other map[string]*Other
instead of Other map[string]Other
it doesn't crash but I don't get the expected merge results the structures inside the map are replaced instead of merged.
from mergo.
This also panics:
package main
import (
"fmt"
"github.com/imdario/mergo"
)
type Other struct {
Faz map[string]string
}
func main() {
new := map[string]Other{
"NoPanic": Other{Faz: map[string]string{}},
"Panic": Other{},
"AlsoPanic": Other{Faz: nil},
}
new2 := map[string]Other{
"NoPanic": Other{
Faz: map[string]string{
"some": "some2",
},
},
"Panic": Other{
Faz: map[string]string{
"some": "some2",
},
},
"AlsoPanic": Other{
Faz: map[string]string{
"some": "some2",
},
},
}
fmt.Println(new)
fmt.Println(new2)
mergo.Merge(&new, new2, mergo.WithAppendSlice, mergo.WithOverride)
}
from mergo.
I think from my debugging that this is the reason why this is happening: https://stackoverflow.com/a/49147910/2213164
from mergo.
I had something similar. The following code in mergo was causing a panic:
if dst.IsNil() && !src.IsNil() {
dst.Set(reflect.MakeMap(dst.Type()))
}
I fixed it by initialising a map in src
. It seems this particular piece of code is at fault.
from mergo.
Reopening this issue as its PR introduced too many bugs.
from mergo.
Related Issues (20)
- Transformers: How to access underlying datatype HOT 1
- mergo WithSliceDeepCopy into differen types will causes painc
- Missing merge only empty dst and check empty value not work for struct HOT 1
- WithSliceDeepCopy cannot merge nums in slice. Suggestion: Recomplete it as WithRecursiveOverride HOT 1
- Mergo not overriding destination with source HOT 2
- Docs: “Mergo in the wild” inaccurate HOT 2
- Mergo is not overriding destination map key with empty value with WithOverwriteWithEmptyValue
- Add support OSS-Fuzz
- Merge Slices HOT 6
- bool values are not merged properly HOT 7
- New module path breaks go install of package with indirect dependency on mergo HOT 13
- How to overwrite specified field with empty value in struct HOT 1
- Choosing fields of struct to override
- Vanity name makes live hard for developers HOT 9
- Vanity url doesn't redirect to github repo HOT 5
- module declares its path as: dario.cat/mergo but was required as: github.com/imdario/mergo HOT 7
- bool issue HOT 2
- unable to go get package
- dario.cat has expired HOT 3
- When a struct is converted to a map, can the key values of the map be of a custom format?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mergo.