utils

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Overview

Package utils simply defines utility functions and types.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCouldNotExtract occurs when an extraction fails.
	ErrCouldNotExtract = errors.New("utils: could not extract the archive")

	// ErrExtractedFileTooBig occurs when a file to extract is too big.
	ErrExtractedFileTooBig = errors.New("utils: could not extract one or more files from the archive: file too big")
)

Functions

func CleanURL

func CleanURL(str string) string

CleanURL removes all parameters from an URL

func CompareStringLists

func CompareStringLists(X, Y []string) []string

CompareStringLists returns the strings which are present in X but not in Y

func Contains

func Contains(needle string, haystack []string) bool

Contains looks for a string into an array of strings and returns whether the string exists

func Exec

func Exec(dir string, bin string, args ...string) ([]byte, error)

Exec runs the given binary with arguments

func Hash

func Hash(str string) string

Hash returns an unique hash of the given string

func SelectivelyExtractArchive

func SelectivelyExtractArchive(r io.Reader, toExtract []string, maxFileSize int64) (map[string][]byte, error)

SelectivelyExtractArchive extracts the specified files and folders from targz data read from the given reader and store them in a map indexed by file paths

Types

type Stopper

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

Stopper eases the graceful termination of a group of goroutines

func NewStopper

func NewStopper() *Stopper

NewStopper initializes a new Stopper instance

func (*Stopper) Begin

func (s *Stopper) Begin()

Begin indicates that a new goroutine has started.

func (*Stopper) Chan

func (s *Stopper) Chan() chan struct{}

Chan returns the channel on which goroutines could listen to determine if they should stop. The channel is closed when Stop() is called.

func (*Stopper) End

func (s *Stopper) End()

End indicates that a goroutine has stopped.

func (*Stopper) Sleep

func (s *Stopper) Sleep(d time.Duration) bool

Sleep puts the current goroutine on sleep during a duration d Sleep could be interrupted in the case the goroutine should stop itself, in which case Sleep returns false.

func (*Stopper) Stop

func (s *Stopper) Stop()

Stop asks every goroutine to end.

Directories

Path Synopsis
Package errors defines error types that are used in several modules
Package errors defines error types that are used in several modules
Package types defines useful types that are used in database models.
Package types defines useful types that are used in database models.

Jump to

Keyboard shortcuts

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