Documentation
¶
Overview ¶
Package cachedeps downloads and caches pinned files and archives under the per-user OS cache directory (e.g., ${XDG_CACHE_HOME} on Linux, ~/Library/Caches on macOS), so programs use the same artifact versions across machines.
Every dependency is cached at <cache>/<subdir>/<key>: a single file for `Binary` deps, a directory of extracted contents for `TarGz` and `Zip`. The cache key is "<name>-<version>", or just "<name>" when Version is empty. The `Subpath` field on Dependency picks a single entry inside an extracted archive; when empty, `Ensure` returns the extraction directory itself.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// Subdir is the per-application directory under the OS cache root,
// e.g., "myapp". Required.
Subdir string
// Output receives progress messages ("Downloading...", progress
// bar). If nil, progress output is silent.
Output io.Writer
}
Cache stores binary dependencies under <os-cache>/<Subdir>, where <os-cache> is the per-user OS cache directory returned by os.UserCacheDir() (e.g., ${XDG_CACHE_HOME} on Linux, ~/Library/Caches on macOS).
type Dependency ¶
type Dependency struct {
Name string
Version string
Format Format
URLs map[Platform]string
SHA256 map[Platform]string
Subpath string
Strip int
}
Dependency describes one cacheable artifact. Name is required. Version is optional and, when set, becomes part of the on-disk cache key so different versions sit side by side. URLs are keyed by the platforms supported. SHA256 is keyed the same way and may be left nil or empty to skip checksum verification; when SHA256 is non-empty but lacks an entry for the host platform, Ensure errors out rather than silently skipping. Subpath, optional and ignored when Format is Binary, names a specific entry inside an extracted archive (e.g., "go/bin/go"); when empty, Ensure returns the path to the extraction directory. Strip drops the first N path components from each archive entry during extraction (analogous to tar --strip-components); 0 leaves the layout as is, and Strip is ignored when Format is Binary.
func (Dependency) CacheKey ¶
func (d Dependency) CacheKey() string
CacheKey returns the on-disk name for this dependency: "<name>-<version>" when Version is set, or just "<name>" when it is empty.