download

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitHubBaseURL = "https://github.com"

GitHubBaseURL is the host archive URLs are built on. Tests point it at an httptest server; production code never changes it.

Functions

func ArchiveURLFor added in v1.5.0

func ArchiveURLFor(owner, repo, ref string, kind RefKind) string

ArchiveURLFor returns the zip archive URL for a ref of a GitHub repository. Each path segment of the ref is escaped on its own, so a branch such as "release/1.5" keeps its slash.

func CopyDir

func CopyDir(src, dest string) error

func DownloadFile

func DownloadFile(srcURL string) (string, error)

DownloadFile fetches srcURL into a temporary file and returns its path. The caller removes the file.

func DownloadFileContext added in v1.5.0

func DownloadFileContext(ctx context.Context, srcURL string) (string, error)

DownloadFileContext is DownloadFile with cancellation. A non-200 response is returned as an *HTTPStatusError so callers can tell "not found" from a network failure.

func ExtractTarGz

func ExtractTarGz(tarPath, destDir string, stripComponents int) error

func ExtractZip

func ExtractZip(zipPath, destDir string, stripComponents int) error

Types

type GitHubRef

type GitHubRef struct {
	Owner   string
	Repo    string
	Branch  string
	Subpath string
}

func ParseGitHubURL

func ParseGitHubURL(raw string) (*GitHubRef, error)

func (*GitHubRef) ArchiveURL

func (r *GitHubRef) ArchiveURL() string

type HTTPStatusError added in v1.5.0

type HTTPStatusError struct {
	URL        string
	StatusCode int
}

HTTPStatusError reports a download that reached the server but was answered with a status other than 200.

func (*HTTPStatusError) Error added in v1.5.0

func (e *HTTPStatusError) Error() string

type RefKind added in v1.5.0

type RefKind int

RefKind says how a Git ref should be requested from GitHub's archive endpoint. RefAny lets GitHub resolve a branch, tag, or commit by name.

const (
	RefAny RefKind = iota
	RefBranch
	RefTag
)

type SourceKind

type SourceKind int
const (
	SourceGitHub SourceKind = iota
	SourceZipURL
	SourceTarGzURL
	SourceLocalDir
	SourceLocalZipFile
	SourceUnknown
)

func InferSourceKind

func InferSourceKind(src string) SourceKind

Jump to

Keyboard shortcuts

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