From 97cde2aa94c13f504ffb126641f5175193712e8b Mon Sep 17 00:00:00 2001 From: M09Ic Date: Sat, 20 May 2023 18:12:31 +0800 Subject: [PATCH] Fix the bug of json nested error --- internal/db/db.go | 2 +- pkg/entity/entity.go | 1 + pkg/entity/parse.go | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/db/db.go b/internal/db/db.go index 91d82e4..6f02359 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -14,7 +14,7 @@ import ( ) type Result struct { - Source string `json:"source"` + Source string common.Result } diff --git a/pkg/entity/entity.go b/pkg/entity/entity.go index 2c7afbc..d3946a8 100644 --- a/pkg/entity/entity.go +++ b/pkg/entity/entity.go @@ -24,6 +24,7 @@ type Entity struct { Text string `json:"ip"` InfoText string `json:"text"` + Source string `json:"source"` Info interface{} `json:"info"` } diff --git a/pkg/entity/parse.go b/pkg/entity/parse.go index 2ad9d3a..f6827d7 100644 --- a/pkg/entity/parse.go +++ b/pkg/entity/parse.go @@ -58,7 +58,8 @@ func ParseLine(line string) Entities { res := db.Find(dbif.QueryType(e.Type), e.Text) if res != nil { e.InfoText = res.String() - e.Info = res + e.Info = res.Result + e.Source = res.Source es = append(es, e) idx = e.Loc[1] }