downloader

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHeaderRequest      = errors.New("request header error")
	ErrSHA256Mismatch     = errors.New("sha256 mismatch")
	ErrCreateDir          = errors.New("create dir error")
	ErrInvalidFilePath    = errors.New("file path is a directory, not a file")
	ErrGetFileInfo        = errors.New("get file info error")
	ErrCopyExistsFileData = errors.New("error copying existing file data")
	ErrDoRequest          = errors.New("error doing request")
	ErrFileWriting        = errors.New("error writing file")
	ErrNewRequest         = errors.New("error creating request")
	ErrOpenFileExists     = errors.New("error opening existing file")
)

Functions

This section is empty.

Types

type Downloader

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

func New

func New(url, filePath, sha256Sum string, opts ...Option) *Downloader

func (*Downloader) Errors

func (d *Downloader) Errors() <-chan error

func (*Downloader) FileName

func (d *Downloader) FileName() string

func (*Downloader) FileType

func (d *Downloader) FileType() string

func (*Downloader) Start

func (d *Downloader) Start(ctx context.Context)

func (*Downloader) Stats

func (d *Downloader) Stats() <-chan Stats

type Option

type Option func(*options)

func WithCustomClient

func WithCustomClient(client *http.Client) Option

type Stats

type Stats struct {
	Downloaded int64
	TotalSize  int64
	Percent    float64
	Completed  bool
}

Jump to

Keyboard shortcuts

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