compactor

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: Apache-2.0, MIT Imports: 8 Imported by: 1

README

Compactor Build Status codecov Go Report Card PkgGoDev

Tar/Gzip and Zip archive utilities with optional checksum computation.

Usage

Tar/Gzip
package main

import (
	"github.com/joseluisq/compactor"
)

func main() {
	compactor.CreateTarballWithChecksum(
		// 1. a base input path directory (it will be skipped for each archive header)
		"./my-base-dir",
		// 2. archive input file or directory
		"./my-file-or-dir",
		// 3. archive output file
		"~/my-archive.tar.gz",
		// 4. checksum algorithm
		"sha256",
		// 5. checksum output file
		"~/my-archive.CHECKSUM.txt",
	)

	// output files:
	//	~/my-archive.tar.gz
	//	~/my-archive.sha256.tar.txt
}
Zip
package main

import (
	"github.com/joseluisq/compactor"
)

func main() {
	compactor.CreateZipballWithChecksum(
		// 1. a base input path directory (it will be skipped for each archive header)
		"./my-base-dir",
		// 2. archive input file or directory
		"./my-file-or-dir",
		// 3. archive output file
		"~/my-archive.zip",
		// 4. checksum algorithm
		"sha256",
		// 5. checksum output file
		"~/my-archive.CHECKSUM.zip.txt",
	)

	// output files:
	//	~/my-archive.zip
	//	~/my-archive.sha256.zip.txt
}

For more API functionalities take a look at https://pkg.golang.ir/github.com/joseluisq/compactor

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in current work by you, as defined in the Apache-2.0 license, shall be dual licensed as described below, without any additional terms or conditions.

Feel free to send some Pull request or issue.

License

This work is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

© 2020-present Jose Quintana

Documentation

Overview

Package compactor provides Tar/Gzip and Zip archive utilities with optional checksum computation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTarball

func CreateTarball(basePath string, src string, dst string) error

CreateTarball archives and compresses a file or folder (src) using Tar/Gzip to dst (tarball). basePath param specify the base path directory of src path which will be skipped for each archive file header. Otherwise if basePath param is empty then only src path will taken into account.

func CreateTarballWithChecksum

func CreateTarballWithChecksum(basePath string, src string, dst string, checksumAlgo string, checksumDst string) (string, error)

CreateTarballWithChecksum archives and compresses a file or folder (src) using Tar/Gzip to dst (tarball) with checksum (`md5`, `sha1`, `sha256` or `sha512`). It returns the checksum file path or an error. basePath param specify the base path directory of src path which will be skipped for each archive file header. Otherwise if basePath param is empty then only src path will taken into account.

func CreateZipball

func CreateZipball(basePath string, src string, dst string) error

CreateZipball archives and compresses a file or folder (src) using Zip to dst (zipball). basePath param specify the base path directory of src path which will be skipped for each archive file header. Otherwise if basePath param is empty then only src path will taken into account.

func CreateZipballWithChecksum

func CreateZipballWithChecksum(basePath, src string, dst string, checksumAlgo string, checksumDst string) (string, error)

CreateZipballWithChecksum archives and compresses a file or folder (src) using Zip to dst (Zipball) with checksum (`md5`, `sha1`, `sha256` or `sha512`). It returns the checksum file path or an error. basePath param specify the base path directory of src path which will be skipped for each archive file header. Otherwise if basePath param is empty then only src path will taken into account.

Types

type ArchiveFormat

type ArchiveFormat uint8

ArchiveFormat represents the archive output format.

const (
	// ArchiveFormatTar represents the Tar/Gzip output format.
	ArchiveFormatTar ArchiveFormat = iota
	// ArchiveFormatZip represents the Zip output format.
	ArchiveFormatZip
)

Directories

Path Synopsis
pkg
archive
Package archive provides archiving and files compressing using Tar-GZ or Zip formmat.
Package archive provides archiving and files compressing using Tar-GZ or Zip formmat.
checksum
Package checksum provides checksum computation for files using md5, sha1, sha256 and sha512 algorithms.
Package checksum provides checksum computation for files using md5, sha1, sha256 and sha512 algorithms.

Jump to

Keyboard shortcuts

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