archiver

package module
v0.0.0-...-8670831 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

README

go-archiver

This is a no-bells-and-wistles wrapper around Gos compress and archive packages. It aims to ease the usage of those packages while incorporating a few fixes that gists are commonly missing.

Documentation

Index

Constants

View Source
const (
	NoCompression      = gzip.NoCompression
	BestSpeed          = gzip.BestSpeed
	BestCompression    = gzip.BestCompression
	DefaultCompression = gzip.DefaultCompression
	HuffmanOnly        = gzip.HuffmanOnly
)

These constants are copied from the flate package, so that code that imports "archiver" does not also have to import "compress/gzip".

Variables

This section is empty.

Functions

func GzipCompress

func GzipCompress(source string, writer io.Writer, opts ...TarOption) error

GzipCompress fronts tar with a gzip compression stream.

func GzipDecompress

func GzipDecompress(destination string, r io.Reader) error

GzipDecompress fronts tar with a gzip decompression stream.

func Tar

func Tar(source string, writer io.Writer, opts ...TarOption) error

Tar takes a source and a writers and walks 'source' writing each file found to the tar writer. It * skips root * maintains empty folders * does not follow (symbolic) links * respects a .gitignore if it's found in the directory root

func Untar

func Untar(destination string, r io.Reader) error

Untar takes a destination path and a reader. A tar reader loops over the tarfile creating the file structure at 'destination' along the way, and writing the files' contents. TODO: make sure that every file that tries to leave the box is skipped

Types

type TarOption

type TarOption func(*tarOptions)

func ArchiveGitRepo

func ArchiveGitRepo() TarOption

ArchiveGitRepo is a shorthand for HonorGitIgnore and IgnoreDotGit

func CompressionLevel

func CompressionLevel(level int) TarOption

CompressionLevel allows users to the compression level of gzip

func HonorGitIgnore

func HonorGitIgnore() TarOption

HonorGitIgnore will look for a .gitignore file in '.', parse it, and only archive files that are not matched by a rule in this .gitignore file. The current implementation does not support multiple .gitignore files in multiple folders.

func IgnoreDotGit

func IgnoreDotGit() TarOption

IgnoreDotGit does not archive any '.git' folders in any subdirectories.

Jump to

Keyboard shortcuts

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