1 Star 0 Fork 0

wuzpdev/goworld

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
compress.go 832 Bytes
一键复制 编辑 原始数据 按行查看 历史
seis 提交于 2017-10-11 13:49 . use config to set compress format
package compress
import (
"strings"
"github.com/pkg/errors"
"github.com/xiaonanln/goworld/engine/gwlog"
)
type Compressor interface {
Compress(b []byte, c []byte) ([]byte, error)
Decompress(c []byte, b []byte) error
}
var (
errNotFullyCompressed = errors.Errorf("not fully compressed")
)
func NewCompressor(compressFormat string) Compressor {
compressFormat = strings.ToLower(compressFormat)
if compressFormat == "snappy" {
return NewSnappyCompressor()
} else if compressFormat == "gwsnappy" {
return NewGWSnappyCompressor()
} else if compressFormat == "lz4" {
return NewLz4Compressor()
} else if compressFormat == "lzw" {
return NewLzwCompressor()
} else if compressFormat == "flate" {
return NewFlateCompressor()
} else {
gwlog.Panicf("unknown compress format: %s", compressFormat)
return nil
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzpdev/goworld.git
git@gitee.com:wuzpdev/goworld.git
wuzpdev
goworld
goworld
v0.1.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385