util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0, BSD-2-Clause Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const MaxUint16 = int(^uint16(0))

Variables

This section is empty.

Functions

func Bytes

func Bytes(obj interface{ Write(io.Writer) error }) ([]byte, error)

func ColorFromBytes

func ColorFromBytes(cb []byte) (ret balance.Color, err error)

func ColorFromString

func ColorFromString(cs string) (ret balance.Color, err error)

func ContainsDuplicates

func ContainsDuplicates(lst []string) bool

func DbGetMulti

func DbGetMulti(store kvstore.KVStore, keys [][]byte) ([][]byte, error)

func DbSetMulti

func DbSetMulti(store kvstore.KVStore, keys [][]byte, values [][]byte) error

func ExistsFilePath added in v0.1.0

func ExistsFilePath(filePath string) (bool, error)

Exists returns whether the given file or directory exists.

func GentleTruncate added in v0.1.0

func GentleTruncate(s string, length int) string

func GetHashValue

func GetHashValue(obj interface{ Write(io.Writer) error }) hashing.HashValue

func Int64From8Bytes added in v0.1.0

func Int64From8Bytes(b []byte) (int64, error)

func LocateFile added in v0.1.0

func LocateFile(fileName string, relativePath ...string) string

func MustBytes

func MustBytes(obj interface{ Write(io.Writer) error }) []byte

func MustUint16From2Bytes added in v0.1.0

func MustUint16From2Bytes(b []byte) uint16

func MustUint32From4Bytes added in v0.1.0

func MustUint32From4Bytes(b []byte) uint32

func MustUint64From8Bytes added in v0.1.0

func MustUint64From8Bytes(b []byte) uint64

func NanoSecToUnixSec

func NanoSecToUnixSec(ts int64) uint32

func ReadBoolByte

func ReadBoolByte(r io.Reader, cond *bool) error

func ReadByte

func ReadByte(r io.Reader) (byte, error)

func ReadBytes16

func ReadBytes16(r io.Reader) ([]byte, error)

func ReadBytes32

func ReadBytes32(r io.Reader) ([]byte, error)

func ReadColor

func ReadColor(r io.Reader, color *balance.Color) error

func ReadHashValue

func ReadHashValue(r io.Reader, h *hashing.HashValue) error

func ReadInt64

func ReadInt64(r io.Reader, pval *int64) error

func ReadMarshaled added in v0.1.0

func ReadMarshaled(r io.Reader, val encoding.BinaryUnmarshaler) error

ReadMarshaled supports kyber.Point, kyber.Scalar and similar.

func ReadString16

func ReadString16(r io.Reader) (string, error)

func ReadStrings16

func ReadStrings16(r io.Reader) ([]string, error)

func ReadTime

func ReadTime(r io.Reader, ts *time.Time) error

func ReadTransactionId

func ReadTransactionId(r io.Reader, txid *transaction.ID) error

func ReadUint16

func ReadUint16(r io.Reader, pval *uint16) error

func ReadUint32

func ReadUint32(r io.Reader, pval *uint32) error

func ReadUint64

func ReadUint64(r io.Reader, pval *uint64) error

func Short

func Short(s string) string

func TimeNowUnix

func TimeNowUnix() uint32

func Uint16To2Bytes

func Uint16To2Bytes(val uint16) []byte

func Uint32From4Bytes

func Uint32From4Bytes(b []byte) (uint32, error)

func Uint32To4Bytes

func Uint32To4Bytes(val uint32) []byte

func Uint64From8Bytes

func Uint64From8Bytes(b []byte) (uint64, error)

func Uint64To8Bytes

func Uint64To8Bytes(val uint64) []byte

func UnixAfterSec

func UnixAfterSec(sec int) uint32

func ValidPermutation

func ValidPermutation(perm []uint16) bool

func WriteBoolByte

func WriteBoolByte(w io.Writer, cond bool) error

func WriteByte

func WriteByte(w io.Writer, val byte) error

func WriteBytes16

func WriteBytes16(w io.Writer, data []byte) error

func WriteBytes32

func WriteBytes32(w io.Writer, data []byte) error

func WriteInt64

func WriteInt64(w io.Writer, val int64) error

func WriteMarshaled added in v0.1.0

func WriteMarshaled(w io.Writer, val encoding.BinaryMarshaler) error

WriteMarshaled supports kyber.Point, kyber.Scalar and similar.

func WriteString16

func WriteString16(w io.Writer, str string) error

func WriteStrings16

func WriteStrings16(w io.Writer, strs []string) error

func WriteTime

func WriteTime(w io.Writer, ts time.Time) error

func WriteUint16

func WriteUint16(w io.Writer, val uint16) error

func WriteUint32

func WriteUint32(w io.Writer, val uint32) error

func WriteUint64

func WriteUint64(w io.Writer, val uint64) error

Types

type Permutation16

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

Permutation16 deterministic permutation of integers from 0 to size-1

func NewPermutation16

func NewPermutation16(size uint16, seed []byte) *Permutation16

func (*Permutation16) Current

func (perm *Permutation16) Current() uint16

func (*Permutation16) GetArray

func (perm *Permutation16) GetArray() []uint16

func (*Permutation16) Next

func (perm *Permutation16) Next() uint16

func (*Permutation16) Shuffle

func (perm *Permutation16) Shuffle(seed []byte) *Permutation16

type WaitChan added in v0.1.0

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

WaitChan is something similar to sync.WaitGroup, just is based on channels and supports waiting with timeout.

func NewWaitChan added in v0.1.0

func NewWaitChan() *WaitChan

func (*WaitChan) Done added in v0.1.0

func (c *WaitChan) Done()

func (*WaitChan) Reset added in v0.1.0

func (c *WaitChan) Reset()

func (*WaitChan) Wait added in v0.1.0

func (c *WaitChan) Wait()

func (*WaitChan) WaitTimeout added in v0.1.0

func (c *WaitChan) WaitTimeout(timeout time.Duration) bool

Directories

Path Synopsis
package implements simple semaphore with timeout
package implements simple semaphore with timeout

Jump to

Keyboard shortcuts

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