Answer the question
In order to leave comments, you need to log in
How to gracefully end reading bufio.Scaner()?
There is a client and a server. The client sends JSON like this:
writer := bufio.NewWriter(conn)
JSONmessage = []byte(`{"Name":"Alice","Body":"Hello","Time":1294706395881547000}`)
writer.Write(JSONmessage)
for {
scanned := scanr.Scan()
if !scanned {
if err := scanr.Err(); err != nil {
log.Println(err, conn.RemoteAddr())
return err
}
}
currentMessage := ParseJSON(scanr.Bytes())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question