-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic: runtime error: invalid memory address or nil pointer dereference [recovered] #17
Comments
Please, can you provide an example showing how are you calling MergeWithOverwrite and what kind of parameters? |
@imdario Sorry for the delay, my example was more complex so I had to create a simple one. package test
import (
"encoding/json"
"testing"
"github.com/imdario/mergo"
)
var (
request = `{"timestamp":null, "name": "foo"}`
maprequest = map[string]interface{}{
"timestamp": nil,
"name": "foo",
"newStuff": "foo",
}
)
func TestMergeWithOverwrite(t *testing.T) {
var something map[string]interface{}
if err := json.Unmarshal([]byte(request), &something); err != nil {
t.Errorf("Error while Unmarshalling maprequest %s", err)
}
if err := mergo.MergeWithOverwrite(&something, maprequest); err != nil {
t.Errorf("Error while merging %s", err)
}
} |
Ok, working on it. I add it as an unit test and I'm checking it. |
Done. There was missing an "if" to check if the value from src was nil. I should check if there is another corner case like this in other points of the code. |
I'm getting an error
The text was updated successfully, but these errors were encountered: