webget

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Unlicense Imports: 8 Imported by: 1

README

go-webget

A little like that wget thing, only much simpler and absolutely toothless in comparsion. But it downloads files from the internet and saves them to your harddisk or loads the content into memory.

That's basically it.

Have a look at the examples if you need to know more.

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = time.Second * 60
	TempExtension  = ".godownload"
)

Variables

This section is empty.

Functions

func DownloadToBuffer

func DownloadToBuffer(sourceURL string, options *Options) ([]byte, error)

func DownloadToFile

func DownloadToFile(sourceURL, targetDir, targetFilename string, options *Options) error

Types

type Options

type Options struct {
	ProgressHandler ProgressHandler
	Timeout         time.Duration
	CreateTargetDir bool
}

func DefaultOptions

func DefaultOptions() *Options

type ProgressHandler

type ProgressHandler interface {
	Start(soureURL string)
	Update(soureURL string, percentage float64, bytes, contentLength int64)
	Done(soureURL string)
}

type ProgressWriter

type ProgressWriter struct {
	URL             string
	Filename        string
	BytesRead       int64
	ContentLength   int64
	ProgressHandler *ProgressHandler
	CustomPayload   interface{}
}

func (*ProgressWriter) Update

func (fp *ProgressWriter) Update()

func (*ProgressWriter) Write

func (fp *ProgressWriter) Write(p []byte) (int, error)

Directories

Path Synopsis
examples
concurrent command
simple command
wget command

Jump to

Keyboard shortcuts

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