code: func (bh *Header) DecodeBinary(r io.Reader) error {
  	var (
  		lText, nRef int32
  		err         error
  	)
  	var magic [4]byte
  	err = binary.Read(r, binary.LittleEndian, &magic)
  	if err != nil {
  		return err
  	}
  	if magic != bamMagic {
  		return errors.New("sam: magic number mismatch")
  	}
  	err = binary.Read(r, binary.LittleEndian, &lText)
  	if err != nil {
  		return err
  	}
  	if lText < 0 {
  		return errors.New("sam: invalid text length")
  	}
  	text := make([]byte, lText)
  	n, err := r.Read(text)
  	if err != nil {
  		return err
  	}
  	if n != int(lText) {
  		return errors.New("sam: truncated header")
  	}
  	err = bh.UnmarshalText(text)
  	if err != nil {
  		return err
  	}
  	err = binary.Read(r, binary.LittleEndian, &nRef)
  	if err != nil {
  		return err
  	}
  	if nRef < 0 {
  		return errors.New("sam: invalid reference count field")
  	}
  	refs, err := readRefRecords(r, nRef)
  	if err != nil {
  		return err
  	}
  	for _, r := range refs {
  		err = bh.AddReference(r)
  		if err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // DecodeBinary unmarshals a Header from the given io.Reader. The byte
  // stream must be in the format described in the SAM specification,
  // section 4.2.