We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is quite similar to #6 but there is another failure case when Read() returns both data and io.EOF. Here's a sample code.
Read()
io.EOF
*myReader
ReadBits(n >= 8)
package main import ( "fmt" "io" "os" bitstream "github.com/dgryski/go-bitstream" ) type myReader struct { n int } func (e *myReader) Read(p []byte) (int, error) { switch e.n { case 0: p[0] = '\xF0' e.n++ return 1, nil case 1: p[0] = '\x1F' e.n++ return 1, io.EOF default: return 0, io.EOF } } func main() { br := bitstream.NewReader(&myReader{}) b, err := br.ReadBits(4) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1) } fmt.Printf("%q\n", b) b, err = br.ReadBits(8) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1) } fmt.Printf("%q\n", b) b, err = br.ReadBits(4) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) } fmt.Printf("%q\n", b) _, err = br.ReadBits(4) if err != io.EOF { panic("unreachable") } }
The result is
'\x0f' EOF exit status 1
But, I expect the following output, no error.
'\x0f' '\x01' '\x0f'
The text was updated successfully, but these errors were encountered:
@dgryski Any thoughts?
Sorry, something went wrong.
No branches or pull requests
This is quite similar to #6 but there is another failure case when
Read()
returns both data andio.EOF
.Here's a sample code.
*myReader
returnsio.EOF
with the last byte.ReadBits(n >= 8)
including the last byte.The result is
But, I expect the following output, no error.
The text was updated successfully, but these errors were encountered: