gzipKit

package
v3.1.101 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LevelNoCompression = gzip.NoCompression

	LevelBestSpeed = gzip.BestSpeed

	LevelBestCompression = gzip.BestCompression
)

Variables

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 (
	Decompress func(data []byte) ([]byte, error) = gcompress.UnGzip
)
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 Compress added in v3.0.52

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

Compress

PS: 前端的解压,可以参考 notes/_Vue3Projects/ws-client 中的 GzipKit.

func IsValidLevel added in v3.0.52

func IsValidLevel(level int) bool

IsValidLevel

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

Types

type Config added in v3.0.57

type Config struct {
	Level int `json:"level" yaml:"level" validate:"min=-2,max=9"`

	CompressThreshold int `json:"compressThreshold" yaml:"compressThreshold"`
}

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

Jump to

Keyboard shortcuts

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