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, restricts extraction to a single file or directory subtree within the archive: only entries matching Subpath exactly or sitting under Subpath + "/" are written to the cache. Match is against the raw archive path -- if the archive wraps its contents in `wrap/` then `Subpath: "wrap"` is the full directory, not `Subpath: "models"` which names something that doesn't exist at the archive root. When Subpath is empty, the whole archive is extracted. Strip drops the first N path components from each extracted entry's path (analogous to tar --strip-components); 0 leaves the layout as is, and Strip is ignored when Format is Binary. Strip must not exceed the number of components in Subpath when Subpath is set -- otherwise the matched entries would have nothing left and Ensure errors out.
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.