From 75e4f9f96a8dd5ff998971e2198e02603f092390 Mon Sep 17 00:00:00 2001 From: Joachim Viide Date: Thu, 13 Dec 2018 22:11:26 +0200 Subject: [PATCH] JSON lines --- main.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 09387fd..4d5df45 100644 --- a/main.go +++ b/main.go @@ -587,7 +587,6 @@ func main() { w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - writeAndFlush(w, "[") stream := tracker.Get(id) if stream == nil { @@ -642,25 +641,16 @@ func main() { goal = result.IP.Equal(ip) } - if err := write(w, "\n "); err != nil { - log.Panic(err) - } if err := writeJSON(w, obj); err != nil { log.Panic(err) } - if !goal { - if err := writeAndFlush(w, ","); err != nil { - log.Panic(err) - } + if err := write(w, "\n"); err != nil { + log.Panic(err) } if goal { break } } - - if err := writeAndFlush(w, "\n]\n"); err != nil { - log.Panic(err) - } }) fmt.Printf("Serving on %v...\n", s.HostPort())