Documentation ¶
Index ¶
- func Assert(x ...interface{})
- func Check(err error)
- func CheckPassword(hash, password, salt string) bool
- func Convert(t time.Time) time.Time
- func GetErrorCode(err *Error) byte
- func GetHash(password, salt string) string
- func Max(a, b uint) uint
- func MaxF(a, b float32) float32
- func Min(a, b uint) uint
- func MinF(a, b float32) float32
- func RandString(n int) string
- func RunDaemon(name string, t time.Duration, f func()) chan bool
- func RunTask(name string, t time.Duration, f func()) chan bool
- func Ternary(condition bool, x, y byte) byte
- func TernaryInt(condition bool, x, y int) int
- type Error
- type TryMutex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
func Assert(x ...interface{})
Assert is an assert function, that is absent in GoLang because of https://golang.org/doc/faq#assertions
func Check ¶
func Check(err error)
Check prints a given error to log, if it exists (othersise method does nothing)
func CheckPassword ¶
CheckPassword verifies that a given "hash" is produced by a given "password"/"salt" pair with BCrypt/SCrypt algorithm
func GetErrorCode ¶
GetErrorCode returns a error code of a given Error
func GetHash ¶
GetHash calculates crypto hash function for a given "password"/"salt" pair with BCrypt/SCrypt algorithm
func RandString ¶
RandString generates a new Random string of length "n" containing latin characters and digits. Taken from https://stackoverflow.com/questions/22892120
func RunDaemon ¶
RunDaemon runs a "background service" that calls function "f" periodically with intervals of "t". Method returns a channel[Bool], so that the daemon can be stopped with "stopMyDaemon <- true" "name" - name of a daemon [optional]
func RunTask ¶
RunTask starts a "background timer" that will call function "f" after a given duration "t". Method returns a channel[Bool], so that the timer can be stopped in advance with "stopMyTimer <- true" "name" - name of a timer [optional]
func Ternary ¶
Ternary is a ternary operator for byte operands. Recall that ternary operator is absent in GoLang because of https://golang.org/doc/faq#Does_Go_have_a_ternary_form. Please be careful, because all the arguments are evaluated! E.g. "b := Ternary(obj != nil, obj.value, 0)" will produce NullPointerException, if obj equals to NULL
func TernaryInt ¶
TernaryInt is a ternary operator for integer operands. Recall that ternary operator is absent in GoLang because of https://golang.org/doc/faq#Does_Go_have_a_ternary_form. Please be careful, because all the arguments are evaluated! E.g. "b := Ternary(obj != nil, obj.value, 0)" will produce NullPointerException, if obj equals to NULL
Types ¶
type Error ¶
Error is a extension of standard Go "error"
func NewErr ¶
NewErr creates a new Error instance from the scratch "who" - the owner component "code" - error code "txt" - error text with optional arguments like %d, %s, etc. "args" - arguments [optional]
func NewErrFromError ¶
NewErrFromError creates a new Error instance from the existing Golang error. "who" - the owner component "code" - error code "err" - base error