From d191aca48905ed88232f36c75ebd2973b954ed3e Mon Sep 17 00:00:00 2001 From: Ke Chen Date: Fri, 24 May 2024 15:13:12 +0800 Subject: [PATCH] feat: yocsef api --- service/yocsef.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/service/yocsef.go b/service/yocsef.go index 3ecd17b..9f300c2 100644 --- a/service/yocsef.go +++ b/service/yocsef.go @@ -80,11 +80,12 @@ func InferYocsef( if err != nil { return nil, err } + line = bytes.Trim(line, " \n\r") if strings.HasPrefix(string(line), "event") { continue } if strings.HasPrefix(string(line), "data") { - line = line[6:] + line = bytes.TrimPrefix(line, []byte("data:")) } line = bytes.Trim(line, " \n\r") if len(line) == 0 { @@ -98,7 +99,7 @@ func InferYocsef( var response map[string]any err = json.Unmarshal(line, &response) if err != nil { - return nil, err + continue } var ok bool