gzipf

package
v0.0.0-...-62718c5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gzipf provides a united interface around gzip and non-gzip files. The functions Open, Create, and Append take the file's suffix in consideration and use gzip streams if needed.

All I/O is buffered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

A Reader reads data from a file. If the file has a .gz or .gzip suffix, it reads decompressed data.

func Open

func Open(path string) (*Reader, error)

Open opens a file for reading. If the file has a .gz or .gzip suffix, its data is decompressed.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the underlying file and gzip stream.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

A Writer writes data to a file. If the file has a .gz or .gzip suffix, it compresses its data.

func Append

func Append(path string) (*Writer, error)

Append opens a file for appending, keeping its existing content. If the file has a .gz or .gzip suffix, it writes compressed data.

func Create

func Create(path string) (*Writer, error)

Create opens a file for writing, deleting any existing content. If the file has a .gz or .gzip suffix, it writes compressed data.

func (*Writer) Close

func (w *Writer) Close() error

Close flushes any buffers and closes the underlying streams.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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