utils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashUtils

func HashUtils() *hashUtils

HashUtils is a factory method that acts as a static member

func JsonUtils

func JsonUtils() *jsonUtils

JsonUtils factory method

func RecoverAll

func RecoverAll(cb func(v any))

RecoverAll performs recover for all panics.

Sample usage:

defer RecoverAll(func(err any) {
	fmt.Printf("got error: %s", err)
})

func RecoverAny

func RecoverAny(errors []error, cb func(v any))

RecoverAny calls the callback function: cb with recovered value in case when recovered value exists in slice errors.

Sample usage:

		defer recover.Any([]error{ErrorUsernameBlank, ErrorUsernameAlreadyTaken}, func(err any) {
 		fmt.Printf("got error: %s", err)
		})

func RecoverOne

func RecoverOne(e error, cb func(v any))

RecoverOne calls the callback function: cb with recovered value in case when recovered value equals to e otherwise panic won't be recovered and will be propagated.

Sample usage:

defer recover.One(ErrorUsernameBlank, func(err any) {
	fmt.Printf("got error: %s", err)
})

func SetAPISecret added in v1.1.2

func SetAPISecret(secret, vector string) error

SetAPISecret set the secret key and initializing vector to encode/decode API keys

func SetJWTSecret added in v1.1.2

func SetJWTSecret(secret string) error

SetJWTSecret set the private key to sign JWT token

func TokenUtils added in v1.1.2

func TokenUtils() *tokenUtils

TokenUtils is a factory method that acts as a static member

Types

This section is empty.

Directories

Path Synopsis
* TTLCache - an in-memory cache with expiration * TTLCache is a simple key/value cache in golang with the following functions: * * 1.
* TTLCache - an in-memory cache with expiration * TTLCache is a simple key/value cache in golang with the following functions: * * 1.

Jump to

Keyboard shortcuts

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