feat(Go-StudyExample):2021/02/09:新增merge源码阅读和单测代码

This commit is contained in:
Huangzj
2021-02-09 16:00:31 +08:00
parent 05f55b0eac
commit cf02f0bf10
51 changed files with 3712 additions and 1 deletions
@@ -0,0 +1,28 @@
package mergo_test
import (
"encoding/json"
"testing"
"github.com/imdario/mergo"
)
func TestIssue17MergeWithOverwrite(t *testing.T) {
var (
request = `{"timestamp":null, "name": "foo"}`
maprequest = map[string]interface{}{
"timestamp": nil,
"name": "foo",
"newStuff": "foo",
}
)
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)
}
}