Skip to content

Commit 3d64a14

Browse files
author
v_llxjliu
committed
fix: 适配 gf框架 gtime
1 parent 4465100 commit 3d64a14

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

filter/parser.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,15 @@ func parserStruct(typeOf reflect.Type, valueOf reflect.Value, t *fieldNodeTree,
285285

286286
valueInterface := value.Interface()
287287
if v, ok := valueInterface.(json.Marshaler); ok {
288-
if _, ok1 := value.Addr().Interface().(GTime); ok1 {
289-
marshalJSON, err := v.MarshalJSON()
290-
if err != nil {
291-
fmt.Println("json marshal error:", err)
292-
} else {
293-
str := string(marshalJSON)
294-
value = reflect.ValueOf(strings.Trim(str, `"`))
288+
if value.CanAddr() {
289+
if _, ok1 := value.Addr().Interface().(GTime); ok1 {
290+
marshalJSON, err := v.MarshalJSON()
291+
if err != nil {
292+
fmt.Println("json marshal error:", err)
293+
} else {
294+
str := string(marshalJSON)
295+
value = reflect.ValueOf(strings.Trim(str, `"`))
296+
}
295297
}
296298
}
297299

0 commit comments

Comments
 (0)