extract

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package extract unpacks tar archives (optionally xz- or gzip-compressed) and writes each regular file into a destination directory, optionally recompressing members with gzip or xz. Member paths are validated against directory traversal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsArchive

func IsArchive(name string) bool

IsArchive reports whether name looks like a tar archive this package can extract: .tar, .tar.gz, .tgz, or .tar.xz.

Types

type Result

type Result struct {
	Files int   // regular files written
	Bytes int64 // total bytes written to disk (post-recompression)
}

Result summarises a single archive extraction.

func Archive

func Archive(archivePath, destDir, comp string) (Result, error)

Archive extracts every regular file from archivePath into destDir, recompressing each member according to comp ("none", "gz", or "xz"). The outer compression is detected from archivePath's extension.

Jump to

Keyboard shortcuts

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