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

struct with unexported fields #38

Closed
TheoBrigitte opened this issue Feb 22, 2017 · 2 comments
Closed

struct with unexported fields #38

TheoBrigitte opened this issue Feb 22, 2017 · 2 comments

Comments

@TheoBrigitte
Copy link
Contributor

TheoBrigitte commented Feb 22, 2017

I came across an issue where struct with unexported fields are not merged.

A good example is type time.Time

package main

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

type Foo struct {
	A string
	B int64
	C time.Time
}

func main() {
	src := Foo{
		A: "one",
		C: time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC),
	}

	dest := Foo{
		B: 2,
		C: time.Date(2010, time.December, 11, 23, 0, 0, 0, time.UTC),
	}

	mergo.MergeWithOverwrite(&dest, src)

	fmt.Println(dest)
	// Expected output
	// {one 2 2009-11-10 23:00:00 +0000 UTC}
	// Actual output
	// {one 2 2010-12-11 23:00:00 +0000 UTC}
}
@darccio
Copy link
Owner

darccio commented Mar 26, 2017

First of all, sorry. Second, I will take care of this this next week.

darccio added a commit that referenced this issue Oct 9, 2017
Fix merge of struct with unexported fields. Issue #38
@darccio
Copy link
Owner

darccio commented Oct 9, 2017

Thanks for your PR!

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