dltools

package
v0.0.0-...-124bb09 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package dltools helps to download files and extract them.

Index

Constants

View Source
const AMD64 = "amd64"

AMD64 is the amd64 GOARCH value

View Source
const ARM64 = "arm64"

ARM64 is the arm64 GOARCH value

View Source
const DARWIN = "darwin"

DARWIN is the darwin GOOS value

View Source
const LINUX = "linux"

LINUX is the linux GOOS value

Variables

This section is empty.

Functions

func Download

func Download(url string, expectedSHA256Hash string) ([]byte, error)

Download saves URL as bytes in memory, verifying a SHA256 hash.

func ExtractTar

func ExtractTar(r io.Reader, destinationDir string, logf LogFunc) error

ExtractTar extracts a tar file from r into destinationDir.

func FormatHashes

func FormatHashes(hashes map[Platform]string) string

FormatHashes returns a string value of hashes to be copy/pasted into code.

func NilLogFunc

func NilLogFunc(message string, args ...interface{})

NilLogFunc does not log anything.

Types

type LogFunc

type LogFunc func(message string, args ...interface{})

LogFunc defines a function for verbose logging.

type PackageFetcher

type PackageFetcher struct {
	// contains filtered or unexported fields
}

PackageFetcher downloads packages for a specific host platform.

func NewPackageFetcher

func NewPackageFetcher(urlTemplate string, hashes map[Platform]string, version string) (*PackageFetcher, error)

NewPackageFetcher creates a new fetcher that uses the provided urlTemplate.

func (*PackageFetcher) ComputeHashes

func (p *PackageFetcher) ComputeHashes() (map[Platform]string, error)

ComputeHashes downloads the packages and computes their hashes for all Platforms.

func (*PackageFetcher) DownloadForCurrentPlatform

func (p *PackageFetcher) DownloadForCurrentPlatform() ([]byte, error)

DownloadForCurrentPlatform downloads the package for the current platform.

func (*PackageFetcher) SetArchMap

func (p *PackageFetcher) SetArchMap(archMap map[string]string) error

SetArchMap configures the GOARCH map for this PackageFetcher.

func (*PackageFetcher) SetOSMap

func (p *PackageFetcher) SetOSMap(osMap map[string]string) error

SetOSMap configures the GOOS map for this PackageFetcher.

type Platform

type Platform struct {
	GOOS   string
	GOARCH string
}

Platform represents the host platform as returned by Go, for use as a map key.

func GetPlatform

func GetPlatform() Platform

GetPlatform returns the current platform from runtime.GOOS and runtime.GOARCH.

func (Platform) String

func (p Platform) String() string

type URLHostPlatform

type URLHostPlatform struct {
	Version string
	OS      string
	Arch    string
}

URLHostPlatform represents the host platform for rendering a URL template.

Jump to

Keyboard shortcuts

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