uncompr

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MPL-2.0 Imports: 9 Imported by: 3

README

uncompr

A Go io.ReadCloser and io.WriteCloser that automatically detects and compresses/decompresses a wide variety of compression formats.

Supported Formats

  • bzip2 (decompression only)
  • gzip
  • lz4
  • xz
  • zstd

Usage

package main

import (
  "fmt" 
  "io"
  "log"
  "os"

  "github.com/dpeckett/uncompr"
)

func main() {
  f, err := os.Open("hello.gz")
  if err != nil {
    log.Fatal(err)
  }
  defer f.Close()

  r, err := uncompr.NewReader(f)
  if err != nil {
    log.Fatal(err)
  }
  defer r.Close()

  contents, err := io.ReadAll(r)
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(string(contents))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReader

func NewReader(r io.Reader) (io.ReadCloser, error)

NewReader returns a reader that decompresses the input stream if it is compressed.

func NewWriter

func NewWriter(w io.Writer, filename string) (io.WriteCloser, error)

NewWriter returns a writer that compresses the output stream based on the file extension.

Types

This section is empty.

Jump to

Keyboard shortcuts

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