pkg

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DownloadURLFormat = "https://dl.google.com/go/go%s.%s-%s.%s"
View Source
var URL = "https://go.dev/dl/?mode=json"
View Source
var VersionURL = "https://go.dev/VERSION?m=text"

Functions

func DownloadGo

func DownloadGo(config DownloadConfig) error

func ExtractGoVersion

func ExtractGoVersion(content string) string

func GetCurrentVersion

func GetCurrentVersion(filePath, directVersion string) (string, error)

func GetLatestVersion

func GetLatestVersion() (string, error)

func IsNewer

func IsNewer(latest, current string) bool

func ReadVersionFromFile

func ReadVersionFromFile(filePath string) (string, error)

func Run

func Run(service VersionChecker, versionFile, currentVersion, targetOS, targetArch string, input io.Reader, output io.Writer) error

Types

type ChecksumCalculator

type ChecksumCalculator interface {
	Calculate(filename string) (string, error)
	GetOfficialChecksum(filename string) (string, error)
}

type DefaultChecksumCalculator

type DefaultChecksumCalculator struct{}

func (*DefaultChecksumCalculator) Calculate

func (c *DefaultChecksumCalculator) Calculate(filename string) (string, error)

func (*DefaultChecksumCalculator) GetOfficialChecksum

func (c *DefaultChecksumCalculator) GetOfficialChecksum(filename string) (string, error)

type DefaultDownloader

type DefaultDownloader struct{}

func (*DefaultDownloader) Download

func (d *DefaultDownloader) Download(url, filename string) error

type DefaultRemover

type DefaultRemover struct{}

func (*DefaultRemover) Remove

func (r *DefaultRemover) Remove(filename string) error

type DownloadConfig added in v2.1.0

type DownloadConfig struct {
	Version    string
	TargetOS   string
	Arch       string
	Path       string
	Downloader FileDownloader
	Remover    FileRemover
	Checksum   ChecksumCalculator
	Input      io.Reader
	Output     io.Writer
}

type FileDownloader

type FileDownloader interface {
	Download(url, filename string) error
}

type FileRemover

type FileRemover interface {
	Remove(filename string) error
}

type GoRelease

type GoRelease struct {
	Version string `json:"version"`
	Stable  bool   `json:"stable"`
	Files   []struct {
		Filename string `json:"filename"`
		OS       string `json:"os"`
		Arch     string `json:"arch"`
		Version  string `json:"version"`
		SHA256   string `json:"sha256"`
	} `json:"files"`
}

type VersionChecker

type VersionChecker interface {
	GetLatestVersion() (string, error)
	GetCurrentVersion(versionFile, currentVersion string) (string, error)
	IsNewer(latestVersion, currentVersion string) bool
	DownloadGo(version, targetOS, arch, path string, input io.Reader, output io.Writer) error
}

type VersionService

type VersionService struct {
	Downloader FileDownloader
	Remover    FileRemover
	Checksum   ChecksumCalculator
	Input      io.Reader
	Output     io.Writer
}

func (*VersionService) DownloadGo

func (v *VersionService) DownloadGo(version, targetOS, arch, path string, input io.Reader, output io.Writer) error

func (*VersionService) GetCurrentVersion

func (v *VersionService) GetCurrentVersion(versionFile, currentVersion string) (string, error)

func (*VersionService) GetLatestVersion

func (v *VersionService) GetLatestVersion() (string, error)

func (*VersionService) IsNewer

func (v *VersionService) IsNewer(latestVersion, currentVersion string) bool

Jump to

Keyboard shortcuts

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