Skip to content

Commit 1ce7211

Browse files
committed
address comments for edge cases
1 parent c08602f commit 1ce7211

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/stream/parse.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ func ParseFile(filename string) error {
4040
continue // skip lines without "data: "
4141
}
4242

43+
// Handle special cases
44+
if line == "[DONE]" {
45+
break // stop processing if we encounter [DONE]
46+
}
47+
if line == "" {
48+
continue // skip empty data lines
49+
}
50+
4351
// Parse the JSON line into our `Data` struct
4452
var data Data
4553
err := json.Unmarshal([]byte(line), &data)

0 commit comments

Comments
 (0)