Documentation
¶
Index ¶
- Constants
- Variables
- func ComparePassword(password, encodedHash string) (bool, error)
- func GetEnv(key, defaultValue string, nonEmpty bool) string
- func GetEnvWithDefault(key, defaultValue string) string
- func GetEnvWithDefaultNE(key, defaultValue string) string
- func HashPassword(password string) (string, error)
- func HashPasswordWithParams(password string, params PasswordHashParams) (string, error)
- func JoinInteger[A interface{ ... }, T Integer](a A, sep string) string
- func MapToType[T any](val any) (T, error)
- func PanicIfError(err error)
- func Pluck[I interface{ ... }, V any, T any](a I, fn func(V) T) []T
- func RandomAlphaNum(length int) (string, error)
- func RandomPrintable(length int) (string, error)
- func RandomString(dict string, length int) (string, error)
- func SliceFindFunc[I any](a []I, fn func(I) bool) I
- func SliceMapFunc[I, O any](a []I, fn func(I) (O, error)) ([]O, error)
- func StringContainsAny(s string, subs []string) bool
- func StringIndexOfAny(s string, subs []string) int
- type Integer
- type PasswordHashParams
- type SimpleTaggedLog
- func (l SimpleTaggedLog) Debugf(format string, args ...interface{})
- func (l SimpleTaggedLog) Errorf(format string, args ...interface{})
- func (l SimpleTaggedLog) Infof(format string, args ...interface{})
- func (l SimpleTaggedLog) PanicIfError(err error)
- func (l SimpleTaggedLog) Panicf(format string, args ...interface{})
Constants ¶
const ( PasswordHashTimesName = "PASSWORD_HASH_TIMES" PasswordHashMemoryName = "PASSWORD_HASH_MEMORY" PasswordHashThreadsName = "PASSWORD_HASH_THREADS" PasswordHashKeyLenName = "PASSWORD_HASH_KEY_LENGTH" PasswordHashSaltLenName = "PASSWORD_HASH_SALT_LENGTH" )
const ( AlphaNum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" Printable = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[]{}|;:,.<>?/`~" )
Variables ¶
Functions ¶
func ComparePassword ¶ added in v0.0.4
ComparePassword compares a password with an encoded hash to check if they match.
func GetEnv ¶ added in v0.0.3
GetEnv returns the value of the environment variable named by the key. It is guaranteed to return the `defaultValue` if the environment variable is not found. If the environment variable is found, it is guaranteed to return the `defaultValue` if the environment variable is empty and `nonEmpty` is `true`.
func GetEnvWithDefault ¶
GetEnvWithDefault returns the value of the environment variable named by the key. It is guaranteed to return the default value if the environment variable is not found or is empty.
func GetEnvWithDefaultNE ¶ added in v0.0.3
GetEnvWithDefaultNE returns the value of the environment variable named by the key. It is guaranteed to return the default value if the environment variable is not found. If the environment variable is found, it is guaranteed to return the default value if the environment variable is empty.
func HashPassword ¶ added in v0.0.4
HashPassword generates a new password hash using the argon2id algorithm.
func HashPasswordWithParams ¶ added in v0.0.4
func HashPasswordWithParams(password string, params PasswordHashParams) ( string, error, )
HashPassword generates a new password hash using the argon2id algorithm.
func JoinInteger ¶ added in v0.0.4
JoinInteger converts a slice of integers to a string, joining them with the separator.
func MapToType ¶ added in v0.0.4
MapToType converts an element of interface{} to an element of specific type, returning an error if the conversion is not possible.
func PanicIfError ¶ added in v0.0.2
func PanicIfError(err error)
PanicIfError panics if the error is not nil.
func Pluck ¶ added in v0.0.4
Pluck extracts a list of values from a slice of structs. The predicate function fn is applied to each element of the slice, and the result is stored in a new slice.
func RandomAlphaNum ¶ added in v0.0.4
func RandomPrintable ¶ added in v0.0.4
func SliceFindFunc ¶ added in v0.0.4
SliceFindFunc returns the first element in the slice that satisfies the predicate function, or the zero value of the element type if none is found.
func SliceMapFunc ¶ added in v0.0.4
SliceMapFunc applies the predicate function to each element of the slice, returning a new slice with the results. If the predicate function returns an error, the function stops and returns the error.
func StringContainsAny ¶ added in v0.0.4
func StringIndexOfAny ¶ added in v0.0.4
Types ¶
type Integer ¶ added in v0.0.4
type Integer interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr }
Integer is a type constraint that includes all integer types
type PasswordHashParams ¶ added in v0.0.4
type PasswordHashParams struct { // Number of iterations Times uint32 // Amount of memory to use, in KB Memory uint32 // Parallelism, number of threads to use Threads uint8 // Key length KeyLen uint32 // Salt length SaltLen uint32 }
func DefaultPasswordHashParams ¶ added in v0.0.4
func DefaultPasswordHashParams() (*PasswordHashParams, error)
type SimpleTaggedLog ¶ added in v0.0.2
type SimpleTaggedLog struct { Debug bool // contains filtered or unexported fields }
func NewDebugLogger ¶ added in v0.0.2
func NewDebugLogger() SimpleTaggedLog
func NewLogger ¶ added in v0.0.2
func NewLogger() SimpleTaggedLog
func WrapLogger ¶ added in v0.0.2
func WrapLogger(logger *lg.Logger, debug bool) SimpleTaggedLog
func (SimpleTaggedLog) Debugf ¶ added in v0.0.2
func (l SimpleTaggedLog) Debugf(format string, args ...interface{})
func (SimpleTaggedLog) Errorf ¶ added in v0.0.2
func (l SimpleTaggedLog) Errorf(format string, args ...interface{})
func (SimpleTaggedLog) Infof ¶ added in v0.0.2
func (l SimpleTaggedLog) Infof(format string, args ...interface{})
func (SimpleTaggedLog) PanicIfError ¶ added in v0.0.2
func (l SimpleTaggedLog) PanicIfError(err error)
func (SimpleTaggedLog) Panicf ¶ added in v0.0.2
func (l SimpleTaggedLog) Panicf(format string, args ...interface{})