Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultLevel 默认的压缩级别,速度最快 DefaultLevel = gzip.BestSpeed // DefaultCompressThreshold 默认的最小压缩长度阈值 DefaultCompressThreshold = -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 CompressComplexly ¶ added in v3.0.52
func CompressComplexly(data []byte, options ...GzipOption) ([]byte, error)
CompressComplexly
PS: 不涉及 compressThreshold 的话,建议直接使用 Compress.
Types ¶
type GzipOption ¶ added in v3.0.52
type GzipOption func(opts *gzipOptions)
func WithCompressThreshold ¶ added in v3.0.57
func WithCompressThreshold(compressThreshold int) GzipOption
WithCompressThreshold 设置: 最小压缩长度阈值
func WithLevel ¶ added in v3.0.52
func WithLevel(level int) GzipOption
Click to show internal directories.
Click to hide internal directories.