Skip to content

feat: Copy to Nil pointer of struct#210

Open
zedisdog wants to merge 1 commit intojinzhu:masterfrom
zedisdog:master
Open

feat: Copy to Nil pointer of struct#210
zedisdog wants to merge 1 commit intojinzhu:masterfrom
zedisdog:master

Conversation

@zedisdog
Copy link
Copy Markdown

@zedisdog zedisdog commented Apr 23, 2024

type struct1 struct {
    A int
}

type struct2 struct {
    A int
}

s1 := struct1{A: 1}
var s2 *struct2

err := copier.Copy(&s2, s1)
if err != nil {
    t.Error("should not error")
}
if s1.A != (*s2).A {
    t.Error("should equal")
}

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

Successfully merging this pull request may close these issues.

1 participant