io.Reader只能读取字节,不能读取位。您可以做的是读取字节并自己提取位:
var ( byte0 byte = 0xAF byte5 byte = 0x89)version := byte0 >> 4headerLength := byte0 & 0x0Fflags := byte5 >> 5
- 当然,另一种方法是编写一个
BitReader
类型,它当然可能会更有效,但是您会明白的:http - //play.golang.org/p/Wyr_K9YAro :)

io.Reader只能读取字节,不能读取位。您可以做的是读取字节并自己提取位:
var ( byte0 byte = 0xAF byte5 byte = 0x89)version := byte0 >> 4headerLength := byte0 & 0x0Fflags := byte5 >> 5
BitReader类型,它当然可能会更有效,但是您会明白的:http