Skip to content

leonardyp/gocopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gocopy

##简化golang结构体相关拷贝

type A struct {
    Id    int64
    Name  *string
    sex   bool
    Uid   int64
    Info  string
    Price float32
}
type B struct {
    Mid  int `cp:"Id"`
    Name string
    Sex  bool
}

func TestCopy(t *testing.T) {
    var str = "demoA"
    a := &A{
        Name:  &str,
        Id:    1,
        Uid:   320,
        Price: 12.3,
        Info:  "info...",
    }
    b := &B{Name: "demo"}
    gocopy.Copy(a, b)
}  

##result:&tests.B{Mid:112, Name:"demoA", Sex:true}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages