goreleases

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 15 Imported by: 2

README

goreleases is a Go package helping you list supported/all Go toolchain releases, and download/verify/extract them.

https://godoc.org/github.com/mjl-/goreleases

MIT-licensed

Documentation

Overview

Package goreleases lists all or supported Go toolchain releases, and download/verify/extract them.

A list of releases is retrieved from go.dev/dl/?mode=json, optionally with the include=all parameter. The released files are assumed to contain just a directory named "go" with a release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(file File, dst string, permissions *Permissions) error

Fetch downloads a toolchain represented, downloads and verifies its gpg signature, and extracts it into directory dst.

After a successful fetch, dst contains a directory "go" with the specified release. Directory dst must exist. It must not already contain a "go" subdirectory.

Only files with filenames ending .tar.gz and .zip can be fetched. Tar.gz files are extracted while fetched. Zip files are first read into memory, then extracted.

If permissions is not nil, it is applied to extracted files and directories.

Types

type File

type File struct {
	Filename string `json:"filename"` // .tar.gz for unix-oriended files (source and binary), .pkg for macOS, .zip and .msi for Windows.
	Os       string `json:"os"`
	Arch     string `json:"arch"`
	Version  string `json:"version"`
	Sha256   string `json:"sha256"`
	Size     int64  `json:"size"`
	Kind     string `json:"kind"` // "source", "archive", "package"
}

File is a released file for a released go version.

func FindFile

func FindFile(release Release, os, arch, kind string) (File, error)

FindFile finds the file in a release for a given os, arch, kind. For empty values of os, arch, kind parameters, any file in the release matches.

type Permissions

type Permissions struct {
	Uid  int
	Gid  int
	Mode os.FileMode // Mode to use for extract files and directories. Files are masked with 0777 or 0666 depending on whether 0100 is set.
}

Permissions to set on extract files and directories, overriding permissions in the archive. Uid and gid are only set when at least one of them is >= 0. Setting uid/gid will fail on Windows.

type Release

type Release struct {
	Version string `json:"version"`
	Stable  bool   `json:"stable"`
	Files   []File `json:"files"`
}

Release is a released Go toolchain version, with files for several Os/Arch combinations.

func ListAll

func ListAll() ([]Release, error)

ListAll returns all Go releases, including historic.

func ListSupported

func ListSupported() ([]Release, error)

ListSupported returns supported Go releases.

Jump to

Keyboard shortcuts

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