util

package
v0.0.0-...-8fa2ce1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password string, hashedPassword []byte) error

func Contains

func Contains(slice []int64, element int64) bool

contains checks if a slice contains an element

func HashPassword

func HashPassword(password string) ([]byte, error)

func Rand

func Rand() *rand.Rand

func RandomCard

func RandomCard() int64

func RandomDessertName

func RandomDessertName() string

RandomDessert generates a random dessert.

func RandomEmail

func RandomEmail() string

func RandomIngredient

func RandomIngredient() string

RandomIngredient generates a random ingredient.

func RandomPoints

func RandomPoints() int32

getRandomPoints returns a random integer between 1 and 10

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n

func RandomSymmetricKey

func RandomSymmetricKey() string

func RandomUsername

func RandomUsername() string

Types

type Config

type Config struct {
	DBDriver             string        `mapstructure:"DB_DRIVER"`
	DBSource             string        `mapstructure:"DB_SOURCE"`
	TestDBSource         string        `mapstructure:"TEST_DB_SOURCE"`
	MigrationURL         string        `mapstructure:"MIGRATION_URL"`
	HTTPServerAddress    string        `mapstructure:"HTTP_SERVER_ADDRESS"`
	GRPCServerAddress    string        `mapstructure:"GRPC_SERVER_ADDRESS"`
	FrontendAddress      string        `mapstructure:"FRONTEND_ADDRESS"`
	TokenSymmetricKey    string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	AccessTokenDuration  time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
	RefreshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
	SmtpHost             string        `mapstructure:"SMTP_HOST"`
	SmtpPort             int           `mapstructure:"SMTP_PORT"`
	SmtpUsername         string        `mapstructure:"SMTP_USERNAME"`
	SmtpPassword         string        `mapstructure:"SMTP_PASSWORD"`
	SmtpSender           string        `mapstructure:"SMTP_SENDER"`
}

TODO: Look into changing TokenSymmetricKey to Asymmetric in production.

func LoadConfig

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

LoadConfig reads configuration from file or environment variables.

Jump to

Keyboard shortcuts

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