-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from devfeel/develop
#### Version 0.7.7 Feature: add Object-oriented interface for the mapper. comment: the old version implementation will be refactored in next release. Tips: Thanks to @shyandsy
- Loading branch information
Showing
14 changed files
with
1,355 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package mapper | ||
|
||
const ( | ||
packageVersion = "0.7.6" | ||
mapperTagKey = "mapper" | ||
jsonTagKey = "json" | ||
IgnoreTagValue = "-" | ||
nameConnector = "_" | ||
formatTime = "15:04:05" | ||
formatDate = "2006-01-02" | ||
formatDateTime = "2006-01-02 15:04:05" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module object | ||
|
||
go 1.16 | ||
|
||
replace github.com/devfeel/mapper v0.7.6 => ./../../../mapper | ||
|
||
require github.com/devfeel/mapper v0.7.6 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/devfeel/mapper" | ||
) | ||
|
||
type ( | ||
User struct { | ||
Name string `json:"name" mapper:"name"` | ||
Age int `json:"age" mapper:"age"` | ||
} | ||
|
||
Student struct { | ||
Name string `json:"name" mapper:"name"` | ||
Age int `json:"age" mapper:"-"` | ||
} | ||
) | ||
|
||
func main() { | ||
user := &User{Name: "test", Age: 10} | ||
student := &Student{} | ||
|
||
// create mapper object | ||
m := mapper.NewMapper() | ||
|
||
// enable the type checking | ||
m.SetEnabledTypeChecking(true) | ||
|
||
student.Age = 1 | ||
|
||
// disable the json tag | ||
m.SetEnabledJsonTag(false) | ||
|
||
// student::age should be 1 | ||
m.Mapper(user, student) | ||
|
||
fmt.Println(student) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module mapper | ||
|
||
go 1.16 | ||
|
||
require github.com/devfeel/mapper v0.7.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/devfeel/mapper v0.7.6 h1:FItOzW4YpEp1x+U1izauW5+sbVIiymOwF7AiWxIdUVk= | ||
github.com/devfeel/mapper v0.7.6/go.mod h1:foz4u16jrssGoDfnWYQGFcthjlU6uBV5UV8uYJfKneA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.