fetch

package
v0.1.85 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package fetch downloads the tools and releases the modlock command needs into the user cache.

Index

Constants

View Source
const MasterTag = "master-build"

MasterTag is the prerelease that holds the newest build of the master branch. Each push to master replaces its files.

Variables

View Source
var ErrSuperseded = errors.New("master has moved on from this build; run modlock update")

ErrSuperseded reports that the master prerelease no longer holds the build asked for, because a later push replaced it.

Functions

func Cache

func Cache(name ...string) (string, error)

Cache returns the directory under the user cache that holds name.

func File

func File(ctx context.Context, url, path string) error

File writes the body at url to path, creating its directory.

func Install

func Install(dir string, fill func(staging string) error) error

Install fills dir once: it runs fill on a staging path beside dir and moves the result into place whole, so an interrupted install never looks complete. It does nothing when dir exists. Each install stages in a directory of its own, so installs of one dir may run at once, in one process or several; the first to finish installs, and the rest find dir in place. fill may keep scratch files, such as a downloaded archive, at staging plus a suffix: they share the private directory, which Install removes.

func LatestMaster added in v0.1.81

func LatestMaster(ctx context.Context) (string, error)

LatestMaster returns the version of the build the master prerelease holds.

func Master added in v0.1.81

func Master(version string) bool

Master reports whether version names a build of the master branch, such as master-0123456789ab.

func MasterVersion added in v0.1.81

func MasterVersion(commit string) string

MasterVersion returns the version of the build of master at commit.

func Published added in v0.1.81

func Published(version string) bool

Published reports whether version has files to download: a release, such as v0.1.9, or a build of master, but not a development build.

func Release

func Release(version, asset string) string

Release returns the address of asset among the files of version: its own release, or the master prerelease for a build of master.

func ReleaseFile added in v0.1.81

func ReleaseFile(ctx context.Context, version, asset, path string) error

ReleaseFile writes asset from the files of version to path. A build of master shares one prerelease with every later build, so ReleaseFile checks after the download that the prerelease still holds version, and returns ErrSuperseded when it does not: the file may belong to a later build.

func Untar

func Untar(archive, name, target string) error

Untar writes the gzipped tar archive's file name to target as an executable.

func UntarTree added in v0.1.4

func UntarTree(archive, prefix, dir string) error

UntarTree writes the regular files under the directory prefix in the gzipped tar archive into dir, keeping their paths below prefix and their modes. An empty prefix writes every file.

func Unzip

func Unzip(archive, name, target string) error

Unzip writes the zip archive's file name to target as an executable.

func Verify

func Verify(path, sum string) error

Verify checks that the file at path has the SHA-256 sum.

func WalkTar

func WalkTar(archive string, visit func(name string, mode fs.FileMode, body io.Reader) error) error

WalkTar calls visit with the cleaned slash-separated name, permission bits and contents of each regular file in the gzipped tar archive at archive, in archive order. It stops at the first error visit returns; fs.SkipAll stops the walk and returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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