type StructuralError … func (s StructuralError) Error() string { … } type reader … // NewReader returns an io.Reader which decompresses bzip2 data from r. // If r does not also implement [io.ByteReader], // the decompressor may read more data than necessary from r. func NewReader(r io.Reader) io.Reader { … } const bzip2FileMagic … const bzip2BlockMagic … const bzip2FinalMagic … // setup parses the bzip2 header. func (bz2 *reader) setup(needMagic bool) error { … } func (bz2 *reader) Read(buf []byte) (n int, err error) { … } func (bz2 *reader) readFromBlock(buf []byte) int { … } func (bz2 *reader) read(buf []byte) (int, error) { … } // readBlock reads a bzip2 block. The magic number should already have been consumed. func (bz2 *reader) readBlock() (err error) { … } // inverseBWT implements the inverse Burrows-Wheeler transform as described in // http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-124.pdf, section 4.2. // In that document, origPtr is called “I” and c is the “C” array after the // first pass over the data. It's an argument here because we merge the first // pass with the Huffman decoding. // // This also implements the “single array” method from the bzip2 source code // which leaves the output, still shuffled, in the bottom 8 bits of tt with the // index of the next byte in the top 24-bits. The index of the first byte is // returned. func inverseBWT(tt []uint32, origPtr uint, c []uint) uint32 { … } var crctab … func init() { … } // updateCRC updates the crc value to incorporate the data in b. // The initial value is 0. func updateCRC(val uint32, b []byte) uint32 { … }