archive

package
v0.11.1-2026 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package archive is used to read and write tar files

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented used for routines that need to be developed still
	ErrNotImplemented = errors.New("this archive routine is not implemented yet")
	// ErrUnknownType used for unknown compression types
	ErrUnknownType = errors.New("unknown compression type")
	// ErrXzUnsupported because there isn't a Go package for this and I'm
	// avoiding dependencies on external binaries
	ErrXzUnsupported = errors.New("xz compression is currently unsupported")
)

Functions

func Compress

func Compress(r io.Reader, oComp CompressType) (io.ReadCloser, error)

func Decompress

func Decompress(r io.Reader) (io.Reader, error)

Decompress extracts gzip and bzip streams

func Extract

func Extract(ctx context.Context, path string, r io.Reader, opts ...TarOpts) error

Extract Tar

func Tar

func Tar(ctx context.Context, path string, w io.Writer, opts ...TarOpts) error

Tar creation

func TarCompressGzip

func TarCompressGzip(to *tarOpts)

TarCompressGzip option to use gzip compression on tar files

func TarUncompressed

func TarUncompressed(to *tarOpts)

TarUncompressed option to tar (noop)

Types

type CompressType

type CompressType int

CompressType identifies the detected compression type

const (
	CompressNone  CompressType = iota // uncompressed or unable to detect compression
	CompressBzip2                     // bzip2
	CompressGzip                      // gzip
	CompressXz                        // xz
	CompressZstd                      // zstd
)

func DetectCompression

func DetectCompression(head []byte) CompressType

DetectCompression identifies the compression type based on the first few bytes

func (CompressType) MarshalText

func (ct CompressType) MarshalText() ([]byte, error)

func (CompressType) String

func (ct CompressType) String() string

func (*CompressType) UnmarshalText

func (ct *CompressType) UnmarshalText(text []byte) error

type TarOpts

type TarOpts func(*tarOpts)

TarOpts configures options for Create/Extract tar

Jump to

Keyboard shortcuts

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