ghrelease

package
v0.0.1-testing Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ghrelease reads GitHub releases and downloads their assets with checksum verification. It is shared by self-update and extensions.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("release not found")

Functions

func FileSHA256

func FileSHA256(path string) (string, error)

FileSHA256 hashes a file on disk.

func ParseChecksums

func ParseChecksums(b []byte) map[string]string

Types

type Asset

type Asset struct {
	Name string `json:"name"`
	URL  string `json:"browser_download_url"`
	Size int64  `json:"size"`
}

type Client

type Client struct {
	HTTP      *http.Client
	APIBase   string
	UserAgent string
	// Token is an optional GitHub token (GH_TOKEN / GITHUB_TOKEN) to raise rate limits.
	Token string
}

func New

func New(userAgent string) *Client

func (*Client) Checksums

func (c *Client) Checksums(ctx context.Context, a *Asset) (map[string]string, error)

Checksums downloads and parses a checksums file ("<sha256> <name>" lines).

func (*Client) Download

func (c *Client) Download(ctx context.Context, a *Asset, w io.Writer) (string, error)

Download streams an asset into w and returns its SHA-256 (hex). Tokens are never sent to download hosts.

func (*Client) Latest

func (c *Client) Latest(ctx context.Context, repo string) (*Release, error)

Latest returns the latest non-prerelease release.

func (*Client) Tag

func (c *Client) Tag(ctx context.Context, repo, tag string) (*Release, error)

Tag returns the release for a tag.

type Release

type Release struct {
	TagName    string  `json:"tag_name"`
	HTMLURL    string  `json:"html_url"`
	Prerelease bool    `json:"prerelease"`
	Assets     []Asset `json:"assets"`
}

func (*Release) Asset

func (r *Release) Asset(name string) (*Asset, bool)

Jump to

Keyboard shortcuts

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