good morning!!!!

Skip to content
Snippets Groups Projects
Commit bf6ac0eb authored by icattlecoder's avatar icattlecoder
Browse files

fix struct time pointer

parent 92abdd15
No related branches found
No related tags found
No related merge requests found
......@@ -278,6 +278,11 @@ func toInternal(val interface{}) interface{} {
switch t := val.(type) {
case []byte:
return string(t)
case *time.Time:
if t == nil || t.IsZero() {
return nil
}
return t.Format(DateFormat)
case time.Time:
return t.Format(DateFormat)
case time.Duration:
......
......@@ -22,6 +22,7 @@
package util
import (
"fmt"
"reflect"
"regexp"
"strings"
......@@ -35,6 +36,7 @@ var reColumnCompareExclude = regexp.MustCompile(`[^a-zA-Z0-9]`)
var (
durationType = reflect.TypeOf(time.Duration(0))
timeType = reflect.TypeOf(time.Time{})
ptimeType = reflect.TypeOf(&time.Time{})
)
type tagOptions map[string]bool
......@@ -146,6 +148,9 @@ func StringToType(src string, dstt reflect.Type) (reflect.Value, error) {
case timeType:
// Destination is time.Time
srcv = reflect.ValueOf(to.Time(src))
case ptimeType:
p := to.Time(src)
srcv = reflect.ValueOf(&p)
default:
return StringToKind(src, dstt.Kind())
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment