download

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSchemeNotSupported        = errors.New("download not supported for given scheme")
	ErrArchiveFormatNotSupported = errors.New("archive format not supported")
	ErrInvalidChecksumFormat     = errors.New("invalid checksum format")
	ErrChecksumAlgoNotSupported  = errors.New("checksum algorithm not supported")
)
View Source
var ErrChecksumMismatch = errors.New("checksum mismatch")

Functions

This section is empty.

Types

type Checksum

type Checksum struct {
	Value []byte
	Hash  hash.Hash
}

func (*Checksum) Checksum

func (c *Checksum) Checksum(src string) error

type DataGetter

type DataGetter struct{}

func (*DataGetter) Get

func (g *DataGetter) Get(ctx context.Context, u *url.URL, dst string) error

type Decompressor

type Decompressor interface {
	Decompress(ctx context.Context, src string, dst string) error
}

type Downloader

type Downloader struct {
	Src              string
	Dst              string
	Getters          map[string]Getter
	Decompressors    map[string]Decompressor
	PostDownloadHook func(string) error
}

func NewDownloader

func NewDownloader(src string, dst string) *Downloader

func (*Downloader) Download

func (d *Downloader) Download(ctx context.Context) error

type Getter

type Getter interface {
	Get(ctx context.Context, u *url.URL, dst string) error
}

type HttpGetter

type HttpGetter struct {
	Client *http.Client
}

func (*HttpGetter) Get

func (g *HttpGetter) Get(ctx context.Context, u *url.URL, dst string) error

type TarDecompressor

type TarDecompressor struct{}

func (*TarDecompressor) Decompress

func (dc *TarDecompressor) Decompress(ctx context.Context, src string, dst string) error

type TarGzipDecompressor

type TarGzipDecompressor struct{}

func (*TarGzipDecompressor) Decompress

func (dc *TarGzipDecompressor) Decompress(ctx context.Context, src string, dst string) error

type ZipDecompressor

type ZipDecompressor struct{}

func (*ZipDecompressor) Decompress

func (dc *ZipDecompressor) Decompress(ctx context.Context, src string, dst string) error

Jump to

Keyboard shortcuts

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