downloads

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download added in v0.8.0

func Download(destDir string, opts DownloadOptions) error

func DownloadToGopathBin

func DownloadToGopathBin(opts DownloadOptions) error

DownloadToGopathBin takes a Go templated URL and expands template variables - srcTemplate is the URL - version is the version to substitute into the template - ext is the file extension to substitute into the template

Template Variables: - {{.GOOS}} - {{.GOARCH}} - {{.EXT}} - {{.VERSION}}

func RenderTemplate

func RenderTemplate(tmplContents string, opts DownloadOptions) (string, error)

RenderTemplate takes a Go templated string and expands template variables Available Template Variables: - {{.GOOS}} - {{.GOARCH}} - {{.EXT}} - {{.VERSION}}

Types

type DownloadOptions

type DownloadOptions struct {
	// UrlTemplate is the Go template for the URL to download. Required.
	// Available Template Variables:
	//   - {{.GOOS}}
	//   - {{.GOARCH}}
	//   - {{.EXT}}
	//   - {{.VERSION}}
	UrlTemplate string

	// Name of the binary, excluding OS specific file extension. Required.
	Name string

	// Version to replace {{.VERSION}} in the URL template. Optional depending on whether or not the version is in the UrlTemplate.
	Version string

	// Ext to replace {{.EXT}} in the URL template. Optional, defaults to xplat.FileExt().
	Ext string

	// OsReplacement maps from a GOOS to the os keyword used for the download. Optional, defaults to empty.
	OsReplacement map[string]string

	// ArchReplacement maps from a GOARCH to the arch keyword used for the download. Optional, defaults to empty.
	ArchReplacement map[string]string

	// Hook to call after downloading the file.
	Hook PostDownloadHook
}

DownloadOptions is the configuration settings used to download a file.

type PostDownloadHook

type PostDownloadHook func(archivePath string) (string, error)

PostDownloadHook is the handler called after downloading a file, which returns the absolute path to the binary.

Jump to

Keyboard shortcuts

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