Documentation ¶
Overview ¶
Package dltools helps to download files and extract them.
Index ¶
- Constants
- func Download(url string, expectedSHA256Hash string) ([]byte, error)
- func ExtractTar(r io.Reader, destinationDir string, logf LogFunc) error
- func FormatHashes(hashes map[Platform]string) string
- func NilLogFunc(message string, args ...interface{})
- type LogFunc
- type PackageFetcher
- type Platform
- type URLHostPlatform
Constants ¶
const AMD64 = "amd64"
AMD64 is the amd64 GOARCH value
const ARM64 = "arm64"
ARM64 is the arm64 GOARCH value
const DARWIN = "darwin"
DARWIN is the darwin GOOS value
const LINUX = "linux"
LINUX is the linux GOOS value
Variables ¶
This section is empty.
Functions ¶
func ExtractTar ¶
ExtractTar extracts a tar file from r into destinationDir.
func FormatHashes ¶
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.
type Platform ¶
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.
type URLHostPlatform ¶
URLHostPlatform represents the host platform for rendering a URL template.