Documentation ¶
Overview ¶
Package util implements various utility functions used within ipfs that do not currently have a better place to live.
Index ¶
- Constants
- Variables
- func ErrCast() error
- func ExpandPathnames(paths []string) ([]string, error)
- func FileExists(filename string) bool
- func FormatRFC3339(t time.Time) string
- func GetenvBool(name string) bool
- func Hash(data []byte) mh.Multihash
- func IsValidHash(s string) bool
- func NewSeededRand(seed int64) io.Reader
- func NewTimeSeededRand() io.Reader
- func ParseRFC3339(s string) (time.Time, error)
- func Partition(subject string, sep string) (string, string, string)
- func RPartition(subject string, sep string) (string, string, string)
- func XOR(a, b []byte) []byte
- type MultiErr
Constants ¶
const DefaultIpfsHash = mh.SHA2_256
DefaultIpfsHash is the current default hash function used by IPFS.
Variables ¶
var Debug bool
Debug is a global flag for debugging.
var ErrNotImplemented = errors.New("error: not implemented yet")
ErrNotImplemented signifies a function has not been implemented yet.
var ErrSearchIncomplete = errors.New("error: search incomplete")
ErrSearchIncomplete implies that a search type operation didn't find the expected node, but did find 'a' node.
var ErrTimeout = errors.New("error: call timed out")
ErrTimeout implies that a timeout has been triggered
var TimeFormatIpfs = time.RFC3339Nano
TimeFormatIpfs is the format ipfs uses to represent time in string form.
Functions ¶
func ErrCast ¶
func ErrCast() error
ErrCast is returned when a cast fails AND the program should not panic.
func ExpandPathnames ¶
ExpandPathnames takes a set of paths and turns them into absolute paths
func FileExists ¶
FileExists check if the file with the given path exits.
func FormatRFC3339 ¶
FormatRFC3339 returns the string representation of the UTC value of the given time in RFC3339Nano format.
func GetenvBool ¶
GetenvBool is the way to check an env var as a boolean
func IsValidHash ¶
IsValidHash checks whether a given hash is valid (b58 decodable, len > 0)
func NewSeededRand ¶
NewSeededRand returns a random bytes reader initialized with the given seed.
func NewTimeSeededRand ¶
NewTimeSeededRand returns a random bytes reader which has been initialized with the current time.
func ParseRFC3339 ¶
ParseRFC3339 parses an RFC3339Nano-formatted time stamp and returns the UTC time.
func Partition ¶
Partition splits a subject 3 parts: prefix, separator, suffix. The first occurrence of the separator will be matched. ie. Partition("Ready, steady, go!", ", ") -> ["Ready", ", ", "steady, go!"]
func RPartition ¶
RPartition splits a subject 3 parts: prefix, separator, suffix. The last occurrence of the separator will be matched. ie. RPartition("Ready, steady, go!", ", ") -> ["Ready, steady", ", ", "go!"]