Skip to content

copier-v0.4.10

Choose a tag to compare

@civet148 civet148 released this 24 Jul 01:24
· 4 commits to master since this release
  • 修复结构体包含同名字段但首字母大小写不同导致拷贝失败问题
import (
	"fmt"
	"testing"
)

type User struct {
	State int32
}
type UserPb struct {
	state int32 //unexported field
	State int32 //exported field
}

func TestCopyExported(t *testing.T) {
	user := User{
		State: 10,
	}
	userPb := UserPb{}
	err := Copy(&userPb, user)
	if err != nil {
		t.Fatal(err)
	}
	fmt.Printf("user pb [%+v]\n", userPb) 
}