util

package
Version: v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package util implements various utility functions used within ipfs that do not currently have a better place to live.

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug is a global flag for debugging.

View Source
var ErrNotFound = ds.ErrNotFound

ErrNotFound is returned when a search fails to find anything

View Source
var ErrNotImplemented = errors.New("Error: not implemented yet.")

ErrNotImplemented signifies a function has not been implemented yet.

View Source
var ErrSearchIncomplete = errors.New("Error: Search Incomplete.")

ErrSeErrSearchIncomplete implies that a search type operation didnt find the expected node, but did find 'a' node.

View Source
var ErrTimeout = errors.New("Error: Call timed out.")

ErrTimeout implies that a timeout has been triggered

View Source
var TimeFormatIpfs = time.RFC3339Nano

Functions

func ContextDo

func ContextDo(ctx context.Context, f func() error) error

func ContextWithErrorLog

func ContextWithErrorLog(parent context.Context) (context.Context, <-chan error)

ContextWithErrorLog returns a copy of parent and an error channel that can be used to receive errors sent with the LogError method.

func ErrCast

func ErrCast() error

ErrCast is returned when a cast fails AND the program should not panic.

func ExpandPathnames

func ExpandPathnames(paths []string) ([]string, error)

ExpandPathnames takes a set of paths and turns them into absolute paths

func FileExists

func FileExists(filename string) bool

func FormatRFC3339

func FormatRFC3339(t time.Time) string

func GetenvBool

func GetenvBool(name string) bool

GetenvBool is the way to check an env var as a boolean

func Hash

func Hash(data []byte) mh.Multihash

Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits

func IsValidHash

func IsValidHash(s string) bool

IsValidHash checks whether a given hash is valid (b58 decodable, len > 0)

func LogError

func LogError(ctx context.Context, err error)

LogError logs the error to the owner of the context.

If this context was created with ContextWithErrorLog, then this method passes the error to context creator over an unbuffered channel.

If this context was created by other means, this method is a no-op.

func NewSeededRand

func NewSeededRand(seed int64) io.Reader

func NewTimeSeededRand

func NewTimeSeededRand() io.Reader

func ParseRFC3339

func ParseRFC3339(s string) (time.Time, error)

func Partition

func Partition(subject string, sep string) (string, string, string)

func RPartition

func RPartition(subject string, sep string) (string, string, string)

func TildeExpansion

func TildeExpansion(filename string) (string, error)

TildeExpansion expands a filename, which may begin with a tilde.

func XOR

func XOR(a, b []byte) []byte

XOR takes two byte slices, XORs them together, returns the resulting slice.

Types

type MultiErr

type MultiErr []error

MultiErr is a util to return multiple errors

func (MultiErr) Error

func (m MultiErr) Error() string

Directories

Path Synopsis
eventlog
loggables
Package loggables includes a bunch of transaltor functions for commonplace/stdlib objects.
Package loggables includes a bunch of transaltor functions for commonplace/stdlib objects.
ci
Package ci implements some helper functions to use during tests.
Package ci implements some helper functions to use during tests.
ci/jenkins
Package jenkins implements some helper functions to use during tests.
Package jenkins implements some helper functions to use during tests.
ci/travis
Package travis implements some helper functions to use during tests.
Package travis implements some helper functions to use during tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL