dwnld

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

dwnld GoDoc

dwnld is a go library for downloading files over http/https or ftp. You can download multiple files at the same time and have a terminal output in realtime.

Example

urls := []string{"https://speed.hetzner.de/100MB.bin", "https://speed.hetzner.de/1GB.bin", "ftp://speedtest.tele2.net/10MB.zip"}

// Create a new downloader manager with configuration
// Here we configure it to download all urls concurently
dwnlder := dwnld.New(dwnld.NewWithMaxConcurrency(-1))

// We start the download
infos := dwnlder.Download(urls...)

// infos contains information about all the downloaded files or the errors
for _, info := range infos {
    fmt.Println(info)
}

Installation

$ go get -v github.com/coopgo/dwnld

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	Path   string
	Silent bool

	// 0 is no concurrency
	// positive is max number of concurrent download
	// negative is no limit to concurrent download
	MaxConcurrency int

	NoConflict bool

	RefreshRate time.Duration
}

func New

func New(opts ...Option) Downloader

func (Downloader) Download

func (dwnlder Downloader) Download(urls ...string) []Info

type Ftp

type Ftp struct {
	User     string
	Password string
	Host     string
	Filepath string
}

type Info

type Info struct {
	Name  string
	Path  string
	Url   string
	Size  int64
	Start time.Time
	End   time.Time
	Error error
}

type Option

type Option func(*Downloader)

func NewWithDefaultPath

func NewWithDefaultPath(path string) Option

func NewWithMaxConcurrency

func NewWithMaxConcurrency(i int) Option

func NewWithNoConflict

func NewWithNoConflict() Option

func NewWithRefreshRate

func NewWithRefreshRate(dur time.Duration) Option

func NewWithSilentOutput

func NewWithSilentOutput() Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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