From bb0a2bd679f3d6d41f733df29cc398a90b26572a Mon Sep 17 00:00:00 2001 From: xiaolong Date: Thu, 2 Jun 2022 20:44:57 +0800 Subject: [PATCH] Update util.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解析出来的目标对象中,可以支持 time.Time 类型的字段 --- internal/converts/util.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/converts/util.go b/internal/converts/util.go index 4530c3e..dd60de4 100644 --- a/internal/converts/util.go +++ b/internal/converts/util.go @@ -31,7 +31,16 @@ func setFieldValue(tag string, field reflect.Value, nValue *nebula_type.Value) e field.SetFloat(nValue.GetFVal()) case reflect.String: field.SetString(string(nValue.GetSVal())) + case reflect.Struct: + switch field.Type().String() { + case "time.Time": + ts := nValue.GetIVal() + field.Set(reflect.ValueOf(time.Unix(ts, 0))) + default: + //fmt.Printf("debug: type[%v] mapping not implement\n", field.Type().String()) + } default: + //fmt.Printf("debug: type[%v] mapping not implement\n", field.Type().String()) return nil } return nil