utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: GPL-3.0 Imports: 12 Imported by: 14

Documentation

Overview

Package utils exports few handy functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreakInIndexes

func BreakInIndexes(id *types.ObjectID, start, end, partSize uint64) []*types.ObjectIndex

BreakInIndexes returns a slice of ObjectIndexes according to the specified byte range [start, end] (inclusive).

func CopyStringSlice

func CopyStringSlice(from []string) []string

CopyStringSlice deeply copies a slice of strings

func FileExists

func FileExists(filePath string) bool

FileExists returns true if filePath is already existing regular file. If it is a directory FileExists will return false.

func IsMetadataFresh

func IsMetadataFresh(obj *types.ObjectMetadata) bool

IsMetadataFresh checks whether the supplied metadata could still be used.

func LimitReadCloser

func LimitReadCloser(readCloser io.ReadCloser, max int) io.ReadCloser

LimitReadCloser wraps a io.ReadCloser but stops with EOF after `max` bytes.

func MultiReadCloser

func MultiReadCloser(readerClosers ...io.ReadCloser) io.ReadCloser

MultiReadCloser returns a io.ReadCloser that's the logical concatenation of the provided input readers.

func MultiWriteCloser

func MultiWriteCloser(writers ...io.WriteCloser) io.WriteCloser

MultiWriteCloser creates a writer that duplicates its writes to all the provided writers, similar to the Unix tee(1) command.

func NewCompositeError

func NewCompositeError(errors ...error) error

NewCompositeError returns a new CompositeError with the supplied errors. The error interface is returned because of this: https://golang.org/doc/faq#nil_error

func NewErrorWithStack added in v0.1.1

func NewErrorWithStack(msg string) error

NewErrorWithStack returns a new error with the current stack

func NopCloser

func NopCloser(w io.Writer) io.WriteCloser

NopCloser returns a WriteCloser with a no-op Close method wrapping the provided Writer w.

func ProjectPath

func ProjectPath() (string, error)

ProjectPath returns a path to the project source as an absolute directory name.

func SkipReadCloser

func SkipReadCloser(readCloser io.ReadCloser, skip int64) io.ReadCloser

SkipReadCloser wraps a io.ReadCloser and ignores the first `skip` bytes.

func WrapErrorWithStack added in v0.1.1

func WrapErrorWithStack(err error) error

WrapErrorWithStack returns an error with the current stack wrapping the provided one

Types

type CompositeError

type CompositeError []error

CompositeError is used for saving multiple errors. IMPORTANT: *NOT* safe for concurrent usage

func (*CompositeError) AppendError

func (c *CompositeError) AppendError(err error)

AppendError is used for adding another error to the list.

func (*CompositeError) Empty

func (c *CompositeError) Empty() bool

Empty returns true if the internal error list is empty.

func (*CompositeError) Error

func (c *CompositeError) Error() string

Returns a string representation of all errors in the order they were appended.

type ErrorWithStack added in v0.1.1

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

ErrorWithStack is an error which wraps around another error and records the current stack

func (*ErrorWithStack) Error added in v0.1.1

func (s *ErrorWithStack) Error() string

func (*ErrorWithStack) Original added in v0.1.1

func (s *ErrorWithStack) Original() error

Original returns the original error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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