In many programs, where I use bufio package, lacks the function, that can read certain amount of bytes.
So now I should create function like this:
func ReadSeveralBytes(r *bufio.Reader, n int) ([]byte, error) {
if n == 0 || r == nil {
return nil, nil
}
peeked, err := r.Peek(n)
if err != nil {
return nil, err
}
if _, err := r.Discard(n); err != nil {
return nil, err
}
return peeked, nil
}
But it's inconvenient and I think, the way it works could be better.
I hope, what I'm not the only one, who wants it in bufio package.