Skip to content

miyukki/bitreader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitreader

Provides basic interfaces to read and traverse an io.Reader as a stream of bits, rather than a stream of bytes.

GoDoc

Installation

$ go get github.com/32bitkid/bitreader

Examples

Ever wanted to count the number of 0 bits from the start of a file?

file, _ := os.Open("file")
br := bitreader.NewBitReader(file)
n := 0
for {
    val, err := br.ReadBit()
    if err != nil || val == true {
        break
    }
    n += 1
}
fmt.Printf("The file starts with %d off bits", n)

But seriously, this is used for parsing densely packed binary formats where data may not be byte aligned. For example, decoding values packed with Huffman Coding.

About

Simple Bitreader for Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%