Documentation ¶
Overview ¶
Package util provides general utility functions shared by the other modules
Index ¶
- func BToMb(b uint64) uint64
- func CreateGUID() string
- func EstSpeed(startTime int64, lastTime int64, bytesSent uint64) uint64
- func Exists(path string) bool
- func FindFile(p string, minRootDir string) string
- func GenRandomBytes(size int) (blk []byte, err error)
- func GetFileSize(fileName string) (int64, error)
- func HumanBytesString(s uint64) string
- func HumanIBytesString(s uint64) string
- func IsDir(path string) bool
- func MinInt(a, b int) int
- func RandomString(n int) string
- func RenderMD(md string) string
- func StringToBool(s string, def bool) bool
- func StringToFloat64(s string, def float64) float64
- func StringToInt16(s string, def int16) int16
- 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 ToTable(rows [][]string, opts TableOpts) 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)
- type SysStats
- type TableOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGUID ¶
func CreateGUID() string
func EstSpeed ¶ added in v1.1.0
EstSpeed will estimate a peers speed using downloaded amount over time
func FindFile ¶ added in v1.0.2
FindFile will walk up the directory tree until it find a file. Max depth of 4 or the minRootDir directory is matched
func GenRandomBytes ¶ added in v1.1.0
GenRandomBytes returns N bytes of random data
func GetFileSize ¶ added in v1.0.1
func HumanBytesString ¶ added in v1.1.0
HumanBytesString produces a human readable representation of an SI size.
Bytes(82854982) -> 83MB noinspection GoUnusedExportedFunction
func HumanIBytesString ¶ added in v1.1.0
HumanIBytesString produces a human readable representation of an IEC size.
IBytes(82854982) -> 79MiB noinspection GoUnusedExportedFunction
func RandomString ¶
func StringToBool ¶ added in v1.1.0
StringToBool converts a string to a bool returning a default value on failure
func StringToFloat64 ¶ added in v1.1.0
StringToFloat64 converts a string to a float64 returning a default value on failure
func StringToInt16 ¶ added in v1.1.0
StringToInt16 converts a string to a int16 returning a default value on failure noinspection GoUnusedExportedFunction
func StringToTime ¶ added in v1.1.0
StringToTime converts a string to a time.Time returning a default value on failure
func StringToUInt ¶ added in v1.1.0
StringToUInt converts a string to a uint32 returning a default value on failure
func StringToUInt16 ¶ added in v1.1.0
StringToUInt16 converts a string to a uint16 returning a default value on failure
func StringToUInt32 ¶ added in v1.1.0
StringToUInt32 converts a string to a uint32 returning a default value on failure
func StringToUInt64 ¶ added in v1.1.0
StringToUInt64 converts a string to a uint32 returning a default value on failure
func TimeToString ¶ added in v1.1.0
TimeToString converts a time.Time to a common RFC1123Z string