Skip to content

zct/Astruct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Astruct

Description

Auto assign struct field. If two struct have same field name and type, then auto assign the field value

Examples

type BasicA struct {
    DiffA  string
	IntList   []int64
	StringMap map[string]string
}


type BasicB struct {
    DiffB string
	IntList   []int64
	StringMap map[string]string
}


var a = &BasicA {
    DiffA :"hello",
    IntList: []int64{1},
    StringMap: map[string]string{"hello":"World"},
}
var b = &BasicB{}

AssignSameFieldStruct(a, b)

fmt.Printf("%#v", b)

output:

{
   DiffB: "",
   IntList: {1}
   StringMap: {"hello":"world"}
}

About

auto assign by same fields in structs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages