Documentation ¶
Overview ¶
Package utils exports few handy functions
Index ¶
- func BreakInIndexes(id *types.ObjectID, start, end, partSize uint64) []*types.ObjectIndex
- func CopyStringSlice(from []string) []string
- func FileExists(filePath string) bool
- func IsMetadataFresh(obj *types.ObjectMetadata) bool
- func LimitReadCloser(readCloser io.ReadCloser, max int) io.ReadCloser
- func MultiReadCloser(readerClosers ...io.ReadCloser) io.ReadCloser
- func MultiWriteCloser(writers ...io.WriteCloser) io.WriteCloser
- func NewCompositeError(errors ...error) error
- func NewErrorWithStack(msg string) error
- func NopCloser(w io.Writer) io.WriteCloser
- func ProjectPath() (string, error)
- func SkipReadCloser(readCloser io.ReadCloser, skip int64) io.ReadCloser
- func WrapErrorWithStack(err error) error
- type CompositeError
- type ErrorWithStack
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 ¶
CopyStringSlice deeply copies a slice of strings
func FileExists ¶
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 ¶
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
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 ¶
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
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