tar

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0, MIT Imports: 10 Imported by: 6

Documentation

Overview

Package tar extracts tar archives to the local filesystem.

Extractor handles tar files containing regular files, directories, and symlinks. Archives must have either a single root file or symlink, or all entries nested under a single root directory. File modes and modification times from the archive are preserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extractor

type Extractor struct {
	Path     string
	Progress func(int64) int64
	// contains filtered or unexported fields
}

Extractor is used for extracting tar files to a filesystem.

The Extractor can only extract tar files containing files, directories and symlinks. Additionally, the tar files must either have a single file, or symlink in them, or must have all of its objects inside of a single root directory object.

If the tar file contains a single file/symlink then it will try and extract it with semantics similar to Linux's `cp`. In particular, the name of the extracted file/symlink will match the extraction path. If the extraction path is a directory then it will extract into the directory using its original name.

If an associated mode and last modification time was stored in the archive it is restored.

Overwriting: Extraction of files and symlinks will result in overwriting the existing objects with the same name when possible (i.e. other files, symlinks, and empty directories).

func (*Extractor) Extract

func (te *Extractor) Extract(reader io.Reader) error

Extract extracts a tar file to the file system. See the Extractor for more information on the limitations on the tar files that can be extracted.

Jump to

Keyboard shortcuts

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