go-gather

module
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0

README

go-gather

go-gather is a library for Go (golang) for downloading ("gathering") from various sources. These sources include:

  • filepaths
  • git
  • http
  • oci

go-gather simplifies the process of gathering from these sources by freeing the implementer from having to be concerned about the details of the sources.

go-gather is based heavily on go-getter, but designed for specific requirements by ec project.

Features

  • Automatic source detection — URI-based routing selects the correct gatherer (file, git, HTTP, OCI) without caller intervention
  • Hardened OCI registry matching — anchored, escaped regex patterns with subdomain-aware matching prevent spoofing via look-alike hostnames
  • Robust URL parsing — proper hostname extraction with case normalization and port stripping for reliable source classification
  • Safe metadata handling — each Gather() call returns an independent metadata snapshot; deferred Close() errors are propagated with context
  • Security-conscious file operations — source files are validated before destination creation to prevent data loss from TOCTOU races

Installation and Use

Installation can be done with a normal go get:

$ go get github.com/conforma/go-gather

Security

All efforts are made to ensure security, but gathering resources from user-provided sources has an intrinsic amount of danger. go-gather attempts to mitigate some of these issues but the user should still use caution in security-critical contexts.

Examples

See the examples directory for examples on how to use this package.

Directories

Path Synopsis
Package detector provides functions to identify URI types (file, git, HTTP, OCI).
Package detector provides functions to identify URI types (file, git, HTTP, OCI).
examples
expand/bzip2 command
expand/tar command
expand/zip command
gather/file command
gather/git command
gather/http command
gather/oci command
registry/gather command
Package expand defines the Expander interface and a registry of expanders for compressed files.
Package expand defines the Expander interface and a registry of expanders for compressed files.
bzip2
Package bzip2 implements an Expander for standalone bzip2 compressed files.
Package bzip2 implements an Expander for standalone bzip2 compressed files.
tar
Package tar implements an Expander for tar archives, including gzip and bzip2 compressed variants.
Package tar implements an Expander for tar archives, including gzip and bzip2 compressed variants.
zip
Package zip implements an Expander for ZIP archives.
Package zip implements an Expander for ZIP archives.
Package gather defines the Gatherer interface and a registry of gatherers.
Package gather defines the Gatherer interface and a registry of gatherers.
file
Package file implements a Gatherer for local filesystem sources.
Package file implements a Gatherer for local filesystem sources.
git
Package git implements a Gatherer for git repository sources.
Package git implements a Gatherer for git repository sources.
http
Package http implements a Gatherer for HTTP and HTTPS sources.
Package http implements a Gatherer for HTTP and HTTPS sources.
oci
Package oci implements a Gatherer for OCI registry sources.
Package oci implements a Gatherer for OCI registry sources.
internal
helpers
Package helpers provides filesystem utilities for copying files, directories, and expanding paths.
Package helpers provides filesystem utilities for copying files, directories, and expanding paths.
oci/network
Package network provides helpers for hostname extraction and loopback detection.
Package network provides helpers for hostname extraction and loopback detection.
oci/registry
Package registry configures OCI registry clients with authentication and TLS settings.
Package registry configures OCI registry clients with authentication and TLS settings.
Package metadata defines the Metadata interface for gather results.
Package metadata defines the Metadata interface for gather results.
Package registry imports all gatherer and expander implementations and exposes convenience lookup functions.
Package registry imports all gatherer and expander implementations and exposes convenience lookup functions.

Jump to

Keyboard shortcuts

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