# README
compressor
解压缩器
- 支持
gzip
方式,以不同的压缩等级进行解压缩 - 支持
snappy
方式解压缩
注意 :
- 默认使用
gzip
方式解压缩
例子
frame := []byte("time.Duration,[]time.Duration,map[string]*Redis此类的非基础类型的slice或者map都需要辅助指明类型")
c, err0 := New(WithType(GZIP), WithLevel(BestSpeed))
xpanic.WhenError(err0)
flatFrame, err1 := c.Flat(frame)
xpanic.WhenError(err1)
inflateFrame, err2 := c.Inflate(flatFrame)
xpanic.WhenError(err2)
xpanic.WhenTrue(string(frame) != string(inflateFrame), "flat/inflate fail")
fmt.Println("OK")
Output:
OK
# Functions
AtomicOptions return atomic *OptionsVisitor.
AtomicOptionsSet atomic setter for *Options.
Flat 默认的压缩器压缩二进制数据.
Inflate 默认的解压二进制数据.
InstallCallbackOnAtomicOptionsSet install callback.
InstallOptionsWatchDog the installed func will called when NewOptions called.
MustNew 初始化 Compressor,否则 panic 当使用 GZIP 方式时,必须传入正确的解压缩等级.
New 初始化 Compressor 使用 GZIP 方式时,解压缩等级才有效,其他模式该参数无效 默认方式,或者使用非 GZIP / Snappy 方式,均为 Dummy 方式.
NewOptions new Options.
go:generate optiongen --option_with_struct_name=false --new_func=NewOptions --xconf=true --empty_composite_nil=true --usage_tag_name=usage.
WithLevel 解压缩等级.
WithType 解压缩类型.
# Variables
No description provided by the author
No description provided by the author
Default 默认的压缩器,使用 GZIP 方式,进行 DefaultCompression 等级的压缩与解压缩.
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
Compressor 压缩器.
OptionsInterface visitor + ApplyOption interface for Options.
OptionsVisitor visitor interface for Options.