func MaybeDecompressReadCloserFromFile(f io.ReadSeekCloser) (io.ReadCloser, error) {
	dt, err := DetectDataType(f)
	if err != nil {
		return nil, err
	}
	// Reset your original reader
	f.Seek(0, 0)

	switch dt {
	case DataTypeGzip:
		return gzip.NewReader(f)
	case DataTypeZip:
		return &readCloserFaker{zipstream.NewReader(f)}, nil
	case DataTypeBZip2:
		return &readCloserFaker{bzip2.NewReader(f)}, nil
	case DataTypeXZ:
		reader, err := xz.NewReader(f, 0)
		if err != nil {
			return nil, err
		}
		return &readCloserFaker{reader}, nil
	case DataTypeZ:
		return zlib.NewReader(f)
	}

	// No data type detected. For now, we assume this is uncompressed.
	return f, nil
}
// MaybeDecompressReadCloserFromFile detects whether a file-like object (must
// implement io.Reader, io.Seeker, and io.Closer) is compressed with GZip, Zip,
// BZip2, XZ, or Z and decompresses it. If not, it returns the file as-is. It
// uses the seek method to ensure that the reader is reset to the starting byte
// so that it does not discard bytes.
MaybeDecompressReadCloserFromFile detects whether a file-like object (must
implement io.Reader, io.Seeker, and io.Closer) is compressed with GZip, Zip,
BZip2, XZ, or Z and decompresses it. If not, it returns the file as-is. It
uses the seek method to ensure that the reader is reset to the starting byte
so that it does not discard bytes.
// MaybeDecompressReadCloserFromFile detects whether a file - like object ( must // implement io . Reader io . Seeker and io . Closer ) is compressed with GZip Zip // BZip2 XZ or Z and decompresses it . If not it returns the file as - is . It // uses the seek method to ensure that the reader is reset to the starting byte // so that it does not discard bytes .
func MaybeDecompressReadCloserFromFile(f io.ReadSeekCloser) (io.ReadCloser, error) {
	dt, err := DetectDataType(f)
	if err != nil {
		return nil, err
	}
	f.Seek(0, 0)
	switch dt {
	case DataTypeGzip:
		return gzip.NewReader(f)
	case DataTypeZip:
		return &readCloserFaker{zipstream.NewReader(f)}, nil
	case DataTypeBZip2:
		return &readCloserFaker{bzip2.NewReader(f)}, nil
	case DataTypeXZ:
		reader, err := xz.NewReader(f, 0)
		if err != nil {
			return nil, err
		}
		return &readCloserFaker{reader}, nil
	case DataTypeZ:
		return zlib.NewReader(f)
	}
	return f, nil
}
func MaybeDecompressReadCloserFromFile ( f io . ReadSeekCloser ) ( io . ReadCloser , error ) { dt , err := DetectDataType ( f ) if err != nil { return nil , err } f . Seek ( 0 , 0 ) switch dt { case DataTypeGzip : return gzip . NewReader ( f ) case DataTypeZip : return & readCloserFaker { zipstream . NewReader ( f ) } , nil case DataTypeBZip2 : return & readCloserFaker { bzip2 . NewReader ( f ) } , nil case DataTypeXZ : reader , err := xz . NewReader ( f , 0 ) if err != nil { return nil , err } return & readCloserFaker { reader } , nil case DataTypeZ : return zlib . NewReader ( f ) } return f , nil }
MaybeDecompressReadCloserFromFile detects whether a file-like object (must
implement io.Reader, io.Seeker, and io.Closer) is compressed with GZip, Zip,
BZip2, XZ, or Z and decompresses it.
MaybeDecompressReadCloserFromFile detects whether a file - like object ( must implement io . Reader io . Seeker and io . Closer ) is compressed with GZip Zip BZip2 XZ or Z and decompresses it .
// Reset your original reader // No data type detected. For now, we assume this is uncompressed.