-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
58 lines (50 loc) · 965 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"dto-mapper/dto"
logUtil "dto-mapper/log"
"dto-mapper/mapper"
"fmt"
"time"
)
func init() {
}
func main() {
ctx := logUtil.NewLoggerInContext()
logger := logUtil.GetLogger(ctx, map[string]interface{}{
"Class": "main",
"Method": "main",
})
input := dto.SourceDto{
Name: dto.Name{
First: "first-input",
Middle: "middle-input",
Last: "last-input",
},
Age: 99,
CreatedAt: time.Now(),
Friends: []dto.Name{
{
First: "first-1",
Middle: "middle-1",
Last: "last-1",
},
{
First: "first-2",
Middle: "middle-2",
Last: "last-2",
},
},
Data: map[string]interface{}{
"key1": 1,
},
}
output := dto.TargetDto{}
fmt.Printf("Input := %v\n", input)
logger.Info("map from source to target")
err := mapper.MapFrom(ctx, input, &output)
if err != nil {
logger.Errorf("Error while mapping.Error := %v", err)
return
}
fmt.Printf("output := %v\n", output)
}