|
|
@@ -19,6 +19,7 @@ const (
|
|
|
const (
|
|
|
tagKey = "assign"
|
|
|
tagPartIgnore = "-"
|
|
|
+ tagPartToPackage = "toPackage"
|
|
|
tagPartToStruct = "toStruct"
|
|
|
tagPartToField = "toField"
|
|
|
tagPartParseTime = "parseTime"
|
|
|
@@ -31,6 +32,7 @@ const (
|
|
|
)
|
|
|
|
|
|
type Tag struct {
|
|
|
+ ToPackage string
|
|
|
ToStruct string
|
|
|
ToField string
|
|
|
ParseTime string
|
|
|
@@ -80,7 +82,8 @@ func parseTag(fromElemValue reflect.Value, toElemValue *reflect.Value, onParsedF
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- if strutils.IsStringNotEmpty(tag.ToStruct) && toElemValue.Type().String() != tag.ToStruct {
|
|
|
+ if (strutils.IsStringNotEmpty(tag.ToPackage) && toElemValue.Type().PkgPath() != tag.ToPackage) ||
|
|
|
+ (strutils.IsStringNotEmpty(tag.ToStruct) && toElemValue.Type().Name() != tag.ToStruct) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -124,6 +127,7 @@ func parseFieldTag(field reflect.StructField, tagStr string) (*Tag, error) {
|
|
|
}
|
|
|
|
|
|
tag := &Tag{
|
|
|
+ ToPackage: "",
|
|
|
ToStruct: "",
|
|
|
ToField: field.Name,
|
|
|
ParseTime: time.DateTime,
|
|
|
@@ -148,6 +152,8 @@ func parseFieldTag(field reflect.StructField, tagStr string) (*Tag, error) {
|
|
|
}
|
|
|
|
|
|
switch tagPartKeyValue[0] {
|
|
|
+ case tagPartToPackage:
|
|
|
+ tag.ToStruct = tagPartKeyValue[1]
|
|
|
case tagPartToStruct:
|
|
|
tag.ToStruct = tagPartKeyValue[1]
|
|
|
case tagPartToField:
|