gzipKit

package
v3.0.52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLevel 默认的压缩级别,速度最快
	DefaultLevel = gzip.BestSpeed

	// DefaultContentLengthThreshold 默认的最小压缩长度阈值
	DefaultContentLengthThreshold = -1
)
View Source
const (
	LevelNoCompression = gzip.NoCompression

	LevelBestSpeed = gzip.BestSpeed

	LevelBestCompression = gzip.BestCompression
)

Variables

View Source
var (
	Compress func(data []byte, level ...int) ([]byte, error) = gcompress.Gzip

	Uncompress func(data []byte) ([]byte, error) = gcompress.UnGzip
)
View Source
var (
	GzipFile func(srcFilePath, dstFilePath string, level ...int) (err error) = gcompress.GzipFile

	GzipPathWriter func(filePath string, writer io.Writer, level ...int) error = gcompress.GzipPathWriter
)
View Source
var (
	UnGzipFile func(srcFilePath, dstFilePath string) error = gcompress.UnGzipFile
)

Functions

func AssertValidLevel added in v3.0.52

func AssertValidLevel(level int) error

func CompressComplexly added in v3.0.52

func CompressComplexly(data []byte, options ...GzipOption) ([]byte, error)

CompressComplexly

PS: 不涉及 contentLengthThreshold 的话,建议直接使用 Compress.

func IsValidLevel added in v3.0.52

func IsValidLevel(level int) bool

IsValidLevel

@param level 有效范围: [-2, 9]

Types

type GzipOption added in v3.0.52

type GzipOption func(opts *gzipOptions)

func WithContentLengthThreshold added in v3.0.52

func WithContentLengthThreshold(contentLengthThreshold int) GzipOption

WithContentLengthThreshold 设置: 最小压缩长度阈值

func WithLevel added in v3.0.52

func WithLevel(level int) GzipOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL