Documentation ¶
Overview ¶
Package util provides general utility functions shared by the other modules
Index ¶
- func EstSpeed(startTime int64, lastTime int64, bytesSent uint64) uint64
- func Exists(path string) bool
- func FindFile(p string) string
- func GenRandomBytes(size int) (blk []byte, err error)
- func HumanBytesString(s uint64) string
- func HumanIBytesString(s uint64) string
- func IsPrivateIP(ip net.IP) bool
- func Min(a, b int) int
- func MinInt(a, b int) int
- func NewPasskey() string
- func Now() time.Time
- func ParseDuration(s string) (time.Duration, error)
- func StringToBool(s string, def bool) bool
- func StringToFloat64(s string, def float64) float64
- func StringToInt16(s string, def int16) int16
- func StringToInt32(s string, def int32) int32
- func StringToTime(s string) time.Time
- func StringToUInt(s string, def int) int
- func StringToUInt16(s string, def uint16) uint16
- func StringToUInt32(s string, def uint32) uint32
- func StringToUInt64(s string, def uint64) uint64
- func TimeToString(t time.Time) string
- func UMax(a, b uint) uint
- func UMax16(a, b uint16) uint16
- func UMax32(a, b uint32) uint32
- func UMax64(a, b uint64) uint64
- func UMin64(a, b uint64) uint64
- func WaitForSignal(ctx context.Context, f func(ctx context.Context) error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenRandomBytes ¶
GenRandomBytes returns N bytes of random data
func HumanBytesString ¶
HumanBytesString produces a human readable representation of an SI size.
Bytes(82854982) -> 83MB noinspection GoUnusedExportedFunction
func HumanIBytesString ¶
HumanIBytesString produces a human readable representation of an IEC size.
IBytes(82854982) -> 79MiB noinspection GoUnusedExportedFunction
func IsPrivateIP ¶
IsPrivateIP returns true if the IP provided is a valid routable address
func NewPasskey ¶
func NewPasskey() string
NewPasskey generated a string suitable for use as a passkey
func ParseDuration ¶
ParseDuration works exactly like time.ParseDuration except that it supports durations longer than hours Formats: s, m, h, d, w, M, y
func StringToBool ¶
StringToBool converts a string to a bool returning a default value on failure
func StringToFloat64 ¶
StringToFloat64 converts a string to a float64 returning a default value on failure
func StringToInt16 ¶
StringToInt16 converts a string to a int16 returning a default value on failure noinspection GoUnusedExportedFunction
func StringToInt32 ¶
StringToInt32 converts a string to a uint32 returning a default value on failure
func StringToTime ¶
StringToTime converts a string to a time.Time returning a default value on failure
func StringToUInt ¶
StringToUInt converts a string to a uint32 returning a default value on failure
func StringToUInt16 ¶
StringToUInt16 converts a string to a uint16 returning a default value on failure
func StringToUInt32 ¶
StringToUInt32 converts a string to a uint32 returning a default value on failure
func StringToUInt64 ¶
StringToUInt64 converts a string to a uint32 returning a default value on failure
func TimeToString ¶
TimeToString converts a time.Time to a common RFC1123Z string
Types ¶
This section is empty.