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 CompressComplexly ¶ added in v3.0.52
func CompressComplexly(data []byte, options ...GzipOption) ([]byte, error)
CompressComplexly
PS: 不涉及 contentLengthThreshold 的话,建议直接使用 Compress.
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
Click to show internal directories.
Click to hide internal directories.