code: func ReadIndex(r io.Reader) (*Index, error) {
  	var (
  		idx   Index
  		magic [4]byte
  		err   error
  	)
  	err = binary.Read(r, binary.LittleEndian, &magic)
  	if err != nil {
  		return nil, err
  	}
  	if magic != baiMagic {
  		return nil, errors.New("bam: magic number mismatch")
  	}
  
  	var n int32
  	err = binary.Read(r, binary.LittleEndian, &n)
  	if err != nil {
  		return nil, err
  	}
  	if n == 0 {
  		return nil, nil
  	}
  	idx.idx, err = internal.ReadIndex(r, n, "bam")
  	if err != nil {
  		return nil, err
  	}
  	return &idx, nil
  }
docs: // ReadIndex reads the BAI Index from the given io.Reader.