code: func WriteTo(w io.Writer, idx *Index) error {
  	idx.sort()
  	err := binary.Write(w, binary.LittleEndian, csiMagic)
  	if err != nil {
  		return err
  	}
  	_, err = w.Write([]byte{idx.Version})
  	if err != nil {
  		return err
  	}
  	err = binary.Write(w, binary.LittleEndian, int32(idx.minShift))
  	if err != nil {
  		return err
  	}
  	err = binary.Write(w, binary.LittleEndian, int32(idx.depth))
  	if err != nil {
  		return err
  	}
  	err = binary.Write(w, binary.LittleEndian, int32(len(idx.Auxilliary)))
  	if err != nil {
  		return err
  	}
  	_, err = w.Write(idx.Auxilliary)
  	if err != nil {
  		return err
  	}
  	binLimit := uint32(((1 << ((idx.depth + 1) * nextBinShift)) - 1) / 7)
  	err = writeIndices(w, idx.Version, idx.refs, binLimit)
  	if err != nil {
  		return err
  	}
  	if idx.unmapped != nil {
  		err = binary.Write(w, binary.LittleEndian, idx.unmapped)
  	}
  	return err
  }
docs: // WriteTo writes the CSI index to the given io.Writer. Note that
  // the csi specification states that the index is stored as BGZF, but
  // WriteTo does not perform compression.