Skip to content

compress checker is a golang package that simplifies identifying compressed data in an efficient manner

License

Notifications You must be signed in to change notification settings

darwayne/compresschecker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compresschecker

compress checker is a golang package that simplifies identifying compressed data in an efficient manner

How efficient is it?

All operations use zero allocations and complete under 40 ns on a modern machine

Supported Compression Formats

  • zstd
  • avro
  • parquet
  • xz
  • rar
  • zip
  • gzip
  • bzip2
  • snappy
  • 7zip

Example Usage

With a Reader

package main

import (
	"fmt"
	"github.com/darwayne/compresschecker"
	"strings"
)

func main() {
	var stream = strings.NewReader("hello word")
	var reader = compresschecker.NewReadChecker(stream)
	defer reader.Close()
	if reader.IsCompressed() {
		fmt.Println("compression detected", reader.CompressionType())
	} else {
		fmt.Println("no compression detected")
    }
}

With a string

package main

import (
	"fmt"
	"github.com/darwayne/compresschecker"
	"strings"
)

func main() {
	var stream = "hello word"
	info := compresschecker.FormatOfString(stream)
	if info.IsCompressed() {
		fmt.Println("compression detected", info)
	} else {
		fmt.Println("no compression detected")
    }
}

With a byte slice

package main

import (
	"fmt"
	"github.com/darwayne/compresschecker"
)

func main() {
	var stream = []byte("hello word")
	info := compresschecker.FormatOfBytes(stream)
	if info.IsCompressed() {
		fmt.Println("compression detected", info)
	} else {
		fmt.Println("no compression detected")
	}
}

About

compress checker is a golang package that simplifies identifying compressed data in an efficient manner

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages