diff options
| -rw-r--r-- | proto/protocol.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/proto/protocol.go b/proto/protocol.go index b59cd70..7a21235 100644 --- a/proto/protocol.go +++ b/proto/protocol.go @@ -4,6 +4,7 @@ import ( "bufio" "strings" "errors" + "io" ) type Object struct { @@ -34,6 +35,9 @@ func ReadLiteral(b *bufio.Reader) (string, error) { var sb strings.Builder for { c, _, err := b.ReadRune() + if errors.Is(err, io.EOF) { + break + } if strings.IndexRune(",;\n", c) != -1 { b.UnreadRune() break @@ -53,6 +57,9 @@ func ReadIdentifier(b *bufio.Reader) (string, error) { var sb strings.Builder for { c, _, err := b.ReadRune() + if errors.Is(err, io.EOF) && sb.Len() > 0 { + break + } if strings.IndexRune("?!*<>:\\,#@~;\n\t ", c) != -1 { b.UnreadRune() break @@ -111,6 +118,9 @@ func ReadObject(b *bufio.Reader) (Object, error) { } o.Fields[key] = value c, _, err = b.ReadRune(); + if errors.Is(err, io.EOF) { + break + } if c == ';' || c == '\n' { b.UnreadRune() break |
