utils

package
v0.0.0-...-e4defeb Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2013 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadTemp

func DownloadTemp(downloader Downloader, url string) (*os.File, error)

DownloadTemp starts new download to temporary file and returns File

Temporary file would be already removed, so no need to cleanup

func DownloadTryCompression

func DownloadTryCompression(downloader Downloader, url string) (io.Reader, *os.File, error)

DownloadTryCompression tries to download from URL .bz2, .gz and raw extension until it finds existing file.

func StrMapsEqual

func StrMapsEqual(m1, m2 map[string]string) bool

StrMapsEqual compares two map[string]string

func StrSlicesEqual

func StrSlicesEqual(s1, s2 []string) bool

StrSlicesEqual compares two slices for equality

func StringsIsSubset

func StringsIsSubset(subset, full []string, errorFmt string) error

StringsIsSubset checks that subset is strict subset of full, and returns error formatted with errorFmt otherwise

Types

type Downloader

type Downloader interface {
	Download(url string, destination string, result chan<- error)
	Shutdown()
}

Downloader is parallel HTTP fetcher

func NewDownloader

func NewDownloader(threads int) Downloader

NewDownloader creates new instance of Downloader which specified number of threads

type FakeDownloader

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

FakeDownloader is like Downloader, but it used in tests to stub out results

func NewFakeDownloader

func NewFakeDownloader() *FakeDownloader

NewFakeDownloader creates new expected downloader

func (*FakeDownloader) Download

func (f *FakeDownloader) Download(url string, filename string, result chan<- error)

Download performs fake download by matching against first expectation in the queue

func (*FakeDownloader) Empty

func (f *FakeDownloader) Empty() bool

Empty verifies that are planned downloads have happened

func (*FakeDownloader) ExpectError

func (f *FakeDownloader) ExpectError(url string, err error) *FakeDownloader

ExpectError installs expectation on upcoming download with error

func (*FakeDownloader) ExpectResponse

func (f *FakeDownloader) ExpectResponse(url string, response string) *FakeDownloader

ExpectResponse installs expectation on upcoming download with response

func (*FakeDownloader) Shutdown

func (f *FakeDownloader) Shutdown()

Shutdown does nothing

Jump to

Keyboard shortcuts

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