util

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 10 Imported by: 209

README

go-ipfs-util

standard-readme compliant

Common utilities used by go-ipfs and other related go packages

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/util. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

Install

This is a Go module which can be installed with go get github.com/ipfs/go-ipfs-util. go-ipfs-util is however packaged with Gx, so it is recommended to use Gx to install it (see Usage section).

Usage

This module is packaged with Gx. In order to use it in your own project do:

go get -u github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go
cd <your-project-repository>
gx init
gx import github.com/ipfs/go-ipfs-util
gx install --global
gx-go --rewrite

Please check Gx and Gx-go documentation for more information.

Want to hack on IPFS?

License

MIT

Documentation

Overview

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

Index

Constants

View Source
const DefaultIpfsHash = mh.SHA2_256

DefaultIpfsHash is the current default hash function used by IPFS.

Deprecated: use github.com/ipfs/boxo/util.DefaultIpfsHash

Variables

View Source
var Debug bool

Debug is a global flag for debugging.

Deprecated: use github.com/ipfs/boxo/util.Debug

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

ErrNotImplemented signifies a function has not been implemented yet.

Deprecated: use github.com/ipfs/boxo/util.ErrNotImplemented

View Source
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.

Deprecated: use github.com/ipfs/boxo/util.ErrSearchIncomplete

View Source
var ErrTimeout = errors.New("error: call timed out")

ErrTimeout implies that a timeout has been triggered

Deprecated: use github.com/ipfs/boxo/util.ErrTimeout

View Source
var TimeFormatIpfs = time.RFC3339Nano

TimeFormatIpfs is the format ipfs uses to represent time in string form.

Deprecated: use github.com/ipfs/boxo/util.TimeFormatIpfs

Functions

func ErrCast deprecated

func ErrCast() error

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

Deprecated: use github.com/ipfs/boxo/util.ErrCast

func ExpandPathnames deprecated

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

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

Deprecated: use github.com/ipfs/boxo/util.ExpandPathnames

func FileExists deprecated

func FileExists(filename string) bool

FileExists check if the file with the given path exits.

Deprecated: use github.com/ipfs/boxo/util.FileExists

func FormatRFC3339 deprecated

func FormatRFC3339(t time.Time) string

FormatRFC3339 returns the string representation of the UTC value of the given time in RFC3339Nano format.

Deprecated: use github.com/ipfs/boxo/util.FormatRFC3339

func GetenvBool deprecated

func GetenvBool(name string) bool

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

Deprecated: use github.com/ipfs/boxo/util.GetenvBool

func Hash deprecated

func Hash(data []byte) mh.Multihash

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

Deprecated: use github.com/ipfs/boxo/util.Hash

func IsValidHash deprecated

func IsValidHash(s string) bool

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

Deprecated: use github.com/ipfs/boxo/util.IsValidHash

func NewSeededRand deprecated

func NewSeededRand(seed int64) io.Reader

NewSeededRand returns a random bytes reader initialized with the given seed.

Deprecated: use github.com/ipfs/boxo/util.NewSeededRand

func NewTimeSeededRand deprecated

func NewTimeSeededRand() io.Reader

NewTimeSeededRand returns a random bytes reader which has been initialized with the current time.

Deprecated: use github.com/ipfs/boxo/util.NewTimeSeededRand

func ParseRFC3339 deprecated

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

ParseRFC3339 parses an RFC3339Nano-formatted time stamp and returns the UTC time.

Deprecated: use github.com/ipfs/boxo/util.ParseRFC3339

func Partition deprecated

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

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!"]

Deprecated: use github.com/ipfs/boxo/util.Partition

func RPartition deprecated

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

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!"]

Deprecated: use github.com/ipfs/boxo/util.RPartition

func XOR deprecated

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

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

Deprecated: use github.com/ipfs/boxo/util.XOR

Types

type MultiErr deprecated

type MultiErr []error

MultiErr is a util to return multiple errors

Deprecated: use github.com/ipfs/boxo/util.MultiErr

func (MultiErr) Error

func (m MultiErr) Error() string

Jump to

Keyboard shortcuts

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