File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
package sseread
2
2
3
3
import (
4
+ "bytes"
4
5
"encoding/json"
5
6
"strings"
6
7
)
@@ -23,6 +24,7 @@ type Event struct {
23
24
// ParseEventLine is a method of the Event struct that parses an event field based on the event type.
24
25
// It takes an event type and event data as input, and updates the corresponding field in the Event struct.
25
26
func (e * Event ) ParseEventLine (lineType string , lineData []byte ) {
27
+
26
28
switch strings .TrimSpace (lineType ) {
27
29
case "event" :
28
30
e .Event = string (lineData ) // If the event type is "event", update the Event field.
@@ -31,6 +33,11 @@ func (e *Event) ParseEventLine(lineType string, lineData []byte) {
31
33
case "retry" :
32
34
e .ID = string (lineData ) // If the event type is "retry", update the Retry field.
33
35
case "data" :
34
- e .Data = lineData // If the event type is "data", update the Data field.
36
+ if bytes .EqualFold (lineData , []byte ("[DONE]" )) {
37
+ e .Data = nil
38
+ } else {
39
+ e .Data = lineData // If the event type is "data", update the Data field.
40
+ }
35
41
}
42
+
36
43
}
You can’t perform that action at this time.
0 commit comments