utils

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: GPL-2.0, GPL-3.0 Imports: 11 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTypeNotSupported = errors.New("type not supported, please feel free to PR")

ErrTypeNotSupported is an error returned if the given type conversion isn't supported yet

Functions

func BToMb added in v1.1.1

func BToMb(b uint64) uint64

BToMb converts bytes (b) to Mb

func GetHomeDir

func GetHomeDir() (string, error)

GetHomeDir gets the home directory of the user

func GetRandomString

func GetRandomString(n int) string

GetRandomString gets a random string of length n

func IntToHumanTime

func IntToHumanTime(inputInt int64) string

IntToHumanTime converts an int64 to human readable time

func PrintMemUsage added in v1.1.1

func PrintMemUsage()

PrintMemUsage outputs the current, total and OS memory being used. As well as the number of garage collection cycles completed.

func SHA3hash

func SHA3hash(inputString string) string

SHA3hash gets the SHA3-512 hash of the passed string

func StringToHumanTime

func StringToHumanTime(inputString string) string

StringToHumanTime converts an int64 in string form to human readable time

func StringToIntTime

func StringToIntTime(inputString string) int64

StringToIntTime converts a string to unix time

func Timestamp

func Timestamp() string

Timestamp gets the human readable timestamp

func ToBigInt

func ToBigInt(x interface{}) (*big.Int, error)

ToBigInt converts a passed interface to big.Int

func ToByte

func ToByte(x interface{}) ([]byte, error)

ToByte converts a passed interface to bytes

func ToFloat

func ToFloat(x interface{}) (float64, error)

ToFloat converts a passed interface to float

func ToInt

func ToInt(x interface{}) (int, error)

ToInt converts a passed interface to int

func ToString

func ToString(x interface{}) (string, error)

ToString converts a passed interface to string

func ToUint16

func ToUint16(x interface{}) (uint16, error)

ToUint16 converts a passed interface to uint16

func Unix

func Unix() int64

Unix gets the unix timestamp

Types

This section is empty.

Jump to

Keyboard shortcuts

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