Skip to content

Commit be29e9c

Browse files
authored
Merge pull request #20 from devfeel/Refactor_mapperObject_refactored_static_implementation
Refactor mapper object refactored static implementation
2 parents a6b4652 + 82c6a7c commit be29e9c

9 files changed

Lines changed: 109 additions & 523 deletions

File tree

constant.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package mapper
22

33
const (
4-
packageVersion = "0.7.6"
4+
packageVersion = "0.7.8"
55
mapperTagKey = "mapper"
66
jsonTagKey = "json"
77
IgnoreTagValue = "-"
88
nameConnector = "_"
99
formatTime = "15:04:05"
1010
formatDate = "2006-01-02"
1111
formatDateTime = "2006-01-02 15:04:05"
12-
)
12+
)

convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func ToInt64(value interface{}) (d int64) {
186186

187187
type argInt []int
188188

189-
// get int by index from int slice
189+
// Get int by index from int slice
190190
func (a argInt) Get(i int, args ...int) (r int) {
191191
if i >= 0 && i < len(a) {
192192
r = a[i]

example/typewrapper/main.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"fmt"
5+
"github.com/devfeel/mapper"
46
"reflect"
57
"time"
68
)
@@ -26,7 +28,7 @@ type decimal struct {
2628
}
2729

2830
type DecimalWrapper struct {
29-
// mapper.BaseTypeWrapper
31+
mapper.BaseTypeWrapper
3032
}
3133

3234
func (w *DecimalWrapper) IsType(value reflect.Value) bool {
@@ -37,14 +39,14 @@ func (w *DecimalWrapper) IsType(value reflect.Value) bool {
3739
}
3840

3941
func main() {
40-
/*
41-
mapper.UseWrapper(&DecimalWrapper{})
42-
user := &User{Name: "test", Age: 10, Score: decimal{value: 1}, Time: time.Now()}
43-
stu := &Student{}
4442

45-
mapper.AutoMapper(user, stu)
43+
mapper.UseWrapper(&DecimalWrapper{})
44+
user := &User{Name: "test", Age: 10, Score: decimal{value: 1}, Time: time.Now()}
45+
stu := &Student{}
46+
47+
mapper.AutoMapper(user, stu)
48+
49+
fmt.Println(user)
50+
fmt.Println(stu)
4651

47-
fmt.Println(user)
48-
fmt.Println(stu)
49-
*/
5052
}

0 commit comments

Comments
 (0)