Documentation
¶
Index ¶
- Variables
- func AddExtension(filename string, algorithm *CompressionAlgorithm) string
- func HasAnyCompressionExtension(filename string) bool
- func HasCompressionExtension(filename string, algorithm *CompressionAlgorithm) bool
- func RemoveExtension(filename string) string
- type CompressionAlgorithm
- type Compressor
Constants ¶
This section is empty.
Variables ¶
var ( Gzip = &CompressionAlgorithm{ Name: "gzip", Extension: ".gz", ContentEncoding: "gzip", } None = &CompressionAlgorithm{ Name: "none", Extension: "", ContentEncoding: "identity", } )
var ErrUnsupportedAlgorithm = errors.New("unsupported compression algorithm")
ErrUnsupportedAlgorithm is returned when an unsupported compression algorithm is specified.
Functions ¶
func AddExtension ¶
func AddExtension(filename string, algorithm *CompressionAlgorithm) string
AddExtension adds the compression extension to the filename if it's not already present.
func HasAnyCompressionExtension ¶ added in v0.0.25
HasCompressionExtension checks if the filename has the compression extension.
func HasCompressionExtension ¶
func HasCompressionExtension(filename string, algorithm *CompressionAlgorithm) bool
HasCompressionExtension checks if the filename has the compression extension.
func RemoveExtension ¶
RemoveExtension removes the compression extension from the filename if it's present.
Types ¶
type CompressionAlgorithm ¶
CompressionAlgorithm represents the type of compression algorithm.
func GetCompressionAlgorithm ¶
func GetCompressionAlgorithm(filename string) (*CompressionAlgorithm, error)
func GetCompressionAlgorithmFromContentEncoding ¶ added in v0.0.25
func GetCompressionAlgorithmFromContentEncoding(contentEncoding string) (*CompressionAlgorithm, error)
type Compressor ¶
type Compressor struct{}
Compressor provides methods for compressing and decompressing data.
func NewCompressor ¶
func NewCompressor() *Compressor
NewCompressor creates a new Compressor instance.
func (*Compressor) Compress ¶
func (c *Compressor) Compress(data *[]byte, algorithm *CompressionAlgorithm) ([]byte, error)
Compress compresses the input data using the specified algorithm.
func (*Compressor) Decompress ¶
func (c *Compressor) Decompress(data *[]byte, filename string) ([]byte, error)
Decompress decompresses the input data using the specified algorithm.