util

package
v0.0.0-...-d59b6e5 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MinPasswordLength = 8

Variables

View Source
var PasswordValidationMessage = fmt.Sprintf("Password should be at least %d characters with at least 1 uppercase, 1 lowercase and 1 special character.", MinPasswordLength)

Functions

func ComparePasswords

func ComparePasswords(password string, hashedPassword string) error

ComparePasswords checks if the input password and hashed password are the same or not.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword turns input password string into a hash.

func IsValidPassword

func IsValidPassword(password string) bool

ValidatePassword checks if password is valid according to the requirements.

func RandomAmount

func RandomAmount() int64

RandomAmount generates a random amount of money.

func RandomCurrency

func RandomCurrency() string

RandomCurrency generates a random currency code.

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email address.

func RandomHex

func RandomHex(n int) (string, error)

RandomHex generates random hex values.

func RandomInt

func RandomInt(min, max int64) int64

RandomInt generates a random int between min and max.

func RandomString

func RandomString(n int) string

RandomString generates a random string of n characters.

func RandomUsername

func RandomUsername() string

RandomUsernam generates a random username.

Types

type Config

type Config struct {
	DBDriver             string        `mapstructure:"DB_DRIVER"`
	DBSource             string        `mapstructure:"DB_SOURCE"`
	ServerAddress        string        `mapstructure:"SERVER_ADDRESS"`
	TokenSymmetricKey    string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	AccessTokenDuration  time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
	RefreshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
}

Config has all configurations of the application. Viper reads the values from a config file or from environment variables. https://github.com/spf13/viper

func LoadConfig

func LoadConfig(path string) (config Config, err error)

LoadConfig reads configuration from a file or environment variables.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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