func (r *Reader) Err() error {
	return r.err
}
Err returns error from last Read. We swallow io.EOF to make it easier
to use
package siser
import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"strconv"
	"time"
)
type Reader struct {
	r *bufio.Reader
	NoTimestamp bool
	Record *Record
	Data      []byte
	Name      string
	Timestamp time.Time
	CurrRecordPos int64
	NextRecordPos int64
	err error
	done bool
}
func NewReader(r *bufio.Reader) *Reader {
	return &Reader{
		r:      r,
		Record: &Record{},
	}
}
func (r *Reader) Done() bool {
	return r.err != nil || r.done
}
func (r *Reader) ReadNextData() bool {
	if r.Done() {
		return false
	}
	r.Name = ""
	r.CurrRecordPos = r.NextRecordPos
	hdr, err := r.r.ReadBytes('\n')
	if err != nil {
		if err == io.EOF {
			r.done = true
		} else {
			r.err = err
		}
		return false
	}
	recSize := len(hdr)
	rest := hdr[:len(hdr)-1]  
	idx := bytes.IndexByte(rest, ' ')
	var dataSize []byte
	if idx == -1 {
		if !r.NoTimestamp {
			r.err = fmt.Errorf("unexpected header '%s'", string(hdr))
			return false
		}
		dataSize = rest
		rest = nil
	} else {
		dataSize = rest[:idx]
		rest = rest[idx+1:]
	}
	var name []byte
	var timestamp []byte
	idx = bytes.IndexByte(rest, ' ')
	if idx == -1 {
		if r.NoTimestamp {
			name = rest
		} else {
			timestamp = rest
		}
	} else {
		timestamp = rest[:idx]
		name = rest[idx+1:]
	}
	size, err := strconv.ParseInt(string(dataSize), 10, 64)
	if err != nil {
		r.err = fmt.Errorf("unexpected header '%s'", string(hdr))
		return false
	}
	if len(timestamp) > 0 {
		timeMs, err := strconv.ParseInt(string(timestamp), 10, 64)
		if err != nil {
			r.err = fmt.Errorf("unexpected header '%s'", string(hdr))
			return false
		}
		r.Timestamp = TimeFromUnixMillisecond(timeMs)
	}
	r.Name = string(name)
	if cap(r.Data) > 1024*1024 {
		r.Data = nil
	}
	if size > int64(cap(r.Data)) {
		r.Data = make([]byte, size)
	} else {
		r.Data = r.Data[:size]
	}
	n, err := io.ReadFull(r.r, r.Data)
	if err != nil {
		r.err = err
		return false
	}
	panicIf(n != len(r.Data))
	recSize += n
	n = len(r.Data)
	needsNewline := (n > 0) && (r.Data[n-1] != '\n')
	if needsNewline {
		_, err = r.r.Discard(1)
		if err != nil {
			r.err = err
			return false
		}
		recSize++
	}
	r.NextRecordPos += int64(recSize)
	return true
}
func (r *Reader) ReadNextRecord() bool {
	ok := r.ReadNextData()
	if !ok {
		return false
	}
	_, r.err = UnmarshalRecord(r.Data, r.Record)
	if r.err != nil {
		return false
	}
	r.Record.Name = r.Name
	r.Record.Timestamp = r.Timestamp
	return true
}