tar

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package tar provides utilities for creating and extracting tar.gz archives.

This package combines the archive/tar and compress/gzip standard libraries to provide convenient functions for working with gzip-compressed tar files.

Features:

  • Compress multiple files and directories into tar.gz
  • Extract tar.gz archives while preserving structure
  • Recursive directory processing
  • File permission and metadata preservation

Example usage:

err := tar.Compress("backup.tar.gz", []string{"./src", "./config"})
err := tar.Decompress("backup.tar.gz", "./restore")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(name string, paths []string) error

Compress compresses multiple files and directories into tar.gz format.

Parameters:

  • name: output tar.gz file path (e.g., "test.tar.gz")
  • paths: slice of file/directory paths to compress

The function recursively processes directories and preserves file permissions.

Example:

err := tar.Compress("test.tar.gz", []string{"./test", "./test.txt"})

func Decompress

func Decompress(name, outputPath string) error

Decompress extracts a tar.gz archive to the specified directory.

Parameters:

  • name: input tar.gz file path (e.g., "test.tar.gz")
  • outputPath: output directory path where files will be extracted

The function preserves directory structure and file permissions.

Example:

err := tar.Decompress("test.tar.gz", "./output")

Types

This section is empty.

Jump to

Keyboard shortcuts

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