package
module
Version:
v0.5.0
Opens a new window with list of versions in this module.
Published: Sep 1, 2024
License: MPL-2.0
Opens a new window with license information.
Imports: 9
Opens a new window with list of imports.
Imported by: 3
Opens a new window with list of known importers.
README
¶
uncompr
A Go io.ReadCloser and io.WriteCloser
that automatically detects and compresses/decompresses a wide variety of compression 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
¶
NewReader returns a reader that decompresses the input stream if it is compressed.
NewWriter returns a writer that compresses the output stream based on the file extension.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.