Categorygithub.com/jeltef/archiver
modulepackage
1.1.2
Repository: https://github.com/jeltef/archiver.git
Documentation: pkg.go.dev

# README

archiver archiver GoDoc Linux Build Status Windows Build Status

Package archiver makes it trivially easy to make and extract common archive formats such as .zip, and .tar.gz. Simply name the input and output file(s).

Files are put into the root of the archive; directories are recursively added.

The archiver command runs the same cross-platform and has no external dependencies (not even libc); powered by the Go standard library, dsnet/compress, and nwaples/rardecode. Enjoy!

Supported formats/extensions:

  • .zip
  • .tar.gz
  • .tgz
  • .tar.bz2
  • .rar (open)

Install

go get github.com/mholt/archiver/cmd/archiver

Or download binaries from the releases page.

Command Use

Make a new archive:

$ archiver make [archive name] [input files...]

(At least one input file is required.)

To extract an archive:

$ archiver open [archive name] [destination]

(The destination path is optional; default is current directory.)

The archive name must end with a supported file extension—this is how it knows what kind of archive to make. Run archiver -h for more help.

Library Use

import "github.com/mholt/archiver"

Create a .zip file:

err := archiver.Zip("output.zip", []string{"file.txt", "folder"})

Extract a .zip file:

err := archiver.Unzip("input.zip", "output_folder")

Working with other file formats is exactly the same, but with their own functions.

FAQ

Can I list a file in one folder to go into a different folder in the archive?

No. This works just like your OS would make an archive in the file explorer: organize your input files to mirror the structure you want in the archive.

Can it add files to an existing archive?

Nope. This is a simple tool; it just makes new archives or extracts existing ones.

# Packages

No description provided by the author

# Functions

Rar makes a .rar archive, but this is not implemented because RAR is a proprietary format.
TarBz2 creates a .tar.bz2 file at tarbz2Path containing the contents of files listed in filePaths.
TarGz creates a .tar.gz file at targzPath containing the contents of files listed in filePaths.
Unrar extracts the RAR file at source and puts the contents into destination.
UntarBz2 untars source and decompresses the contents into destination.
UntarGz untars source and decompresses the contents into destination.
Unzip unzips the .zip file at source into destination.
Zip creates a .zip file in the location zipPath containing the contents of files listed in filePaths.

# Variables

CompressedFormats is a (non-exhaustive) set of lowercased file extensions for formats that are typically already compressed.

# Type aliases

No description provided by the author
No description provided by the author