Skip to content
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

Got an "only structs and maps are supported" on merge two identical structs #92

Closed
iSynth opened this issue Nov 20, 2018 · 1 comment
Closed

Comments

@iSynth
Copy link

iSynth commented Nov 20, 2018

I have a two identical structs and I want to merge them.

type MyStruct struct {
    Field string
}

a := MyStruct{Field:"A"}
b := MyStruct{Field:"B"}

mergo.MergeWithOverwrite(&a, b)

panic: only structs and maps are supported

@darccio
Copy link
Owner

darccio commented Jan 23, 2019

I'm unable to reproduce this. It works as expected:

package main

import (
        "fmt"
        "github.com/imdario/mergo"
)

type MyStruct struct {
    Field string
}

func main() {
        a := MyStruct{Field:"A"}
        b := MyStruct{Field:"B"}

        mergo.MergeWithOverwrite(&a, b)
        fmt.Printf("%v\n", a)
}

Output:

dario@thinkpad /tmp $ go run test_mergo.go
{B}

@darccio darccio closed this as completed Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants