99)
1010
1111type AutoMappingStructSource struct {
12+ Age int
1213 Name string
1314 Time time.Time
1415 UUID uuid.UUID
@@ -18,10 +19,11 @@ type AutoMappingStructSource struct {
1819}
1920
2021type AutoMappingStructDest struct {
22+ UUID uuid.UUID
23+ Age int
2124 Name string
2225 SecondName string
2326 Time time.Time
24- UUID uuid.UUID
2527 PtrTime * time.Time
2628 PtrUUID * uuid.UUID
2729 NestedStruct NestedStructDest
@@ -70,15 +72,24 @@ func TestAutoRoute(t *testing.T) {
7072 dest .PtrTime = & timeNow
7173 }
7274 dest .Time = timeNow
73- }))
75+ }),
76+ WithFieldSkip (func (dest * AutoMappingStructSource ) any {
77+ return & dest .UUID
78+ }),
79+ WithFieldSkip (func (dest * AutoMappingStructSource ) any {
80+ return & dest .Age
81+ }),
82+ )
7483 t .Run ("Auto route with options" , func (t * testing.T ) {
75- source := & AutoMappingStructSource {Name : "Test1" }
84+ source := & AutoMappingStructSource {UUID : uuid . New (), Name : "Test1" , Age : 25 }
7685 dest , err := MapTo [AutoMappingStructDest ](source )
7786 assert .NoError (t , err )
7887 assert .Equal (t , source .Name , dest .Name )
7988 assert .Equal (t , "Test2" , dest .SecondName )
8089 assert .Equal (t , timeNow , * dest .PtrTime )
8190 assert .Equal (t , timeNow , dest .Time )
91+ assert .Equal (t , 0 , dest .Age )
92+ assert .Equal (t , uuid .Nil , dest .UUID )
8293 })
8394 t .Run ("Auto mapping struct fields" , func (t * testing.T ) {
8495 source := & AutoMappingStructSource {
0 commit comments