func (b *bitReader) readByte() (byte, error) {
	if b.count == 0 {
		n, err := b.r.Read(b.buffer[:])
		if err != nil {
			return b.buffer[0], fmt.Errorf("failed to read a byte: %w", err)
		}
		if n != 1 {
			return b.buffer[0], errors.New("read more than a byte")
		}
		return b.buffer[0], nil
	}
	byt := b.buffer[0]
	n, err := b.r.Read(b.buffer[:])
	if err != nil {
		return 0, fmt.Errorf("failed to read a byte: %w", err)
	}
	if n != 1 {
		return b.buffer[0], errors.New("read more than a byte")
	}
	byt |= b.buffer[0] >> b.count
	b.buffer[0] <<= (8 - b.count)
	return byt, nil
}
readByte reads a single byte from the stream, regardless of alignment
package gorilla
import (
	"errors"
	"fmt"
	"io"
)
type bitReader struct {
	r      io.Reader
	buffer [1]byte
	count  uint8
}
func newBitReader(r io.Reader) *bitReader {
	return &bitReader{r: r}
}
func (b *bitReader) readBit() (bit, error) {
	if b.count == 0 {
		n, err := b.r.Read(b.buffer[:])
		if err != nil {
			return zero, fmt.Errorf("failed to read a byte: %w", err)
		}
		if n != 1 {
			return zero, errors.New("read more than a byte")
		}
		b.count = 8
	}
	b.count--
	d := (b.buffer[0] & 0x80)
	b.buffer[0] <<= 1
	return d != 0, nil
}