util

package
v0.0.0-...-82b861d Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password string, hashedPassword string) error

func DateTimeRegExp

func DateTimeRegExp() *regexp.Regexp

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns the bcrypt hash of the password

func NewLogger

func NewLogger(config Config) *zerolog.Logger

func ParseDateTime

func ParseDateTime(s string) (time.Time, bool)

ParseDateTime extracts a valid mobile number from s.

func ParseMobileNumber

func ParseMobileNumber(s string) (string, bool)

ParseMobileNumber extracts a valid mobile number from s.

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email

func RandomFloat

func RandomFloat[T constraints.Float](min, max T) T

RandomFloat generates a random float between min and max

func RandomInt

func RandomInt[T constraints.Integer](min, max T) T

RandomInt generates a random integer between min and max

func RandomMobileNumber

func RandomMobileNumber() string

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n

func ReverseDBMigration

func ReverseDBMigration(migrationPath string, dbSource string) error

func RunDBMigration

func RunDBMigration(migrationPath string, dbSource string) error

func SetDifference

func SetDifference(a, b []string) (diff []string)

Set Difference

func SetIntersection

func SetIntersection(a, b []string) (c []string)

Set Intersection

Types

type Config

type Config struct {
	Environment          string        `mapstructure:"ENVIRONMENT"`
	GinMode              string        `mapstructure:"GIN_MODE"`
	DBDriver             string        `mapstructure:"DB_DRIVER"`
	DBSource             string        `mapstructure:"DB_SOURCE"`
	MigrationPath        string        `mapstructure:"MIGRATION_PATH"`
	HTTPServerAddress    string        `mapstructure:"HTTP_SERVER_ADDRESS"`
	CookieDomain         string        `mapstructure:"COOKIE_DOMAIN"`
	CookiePath           string        `mapstructure:"COOKIE_PATH"`
	TokenSymmetricKey    string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	AccessTokenDuration  time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
	RefreshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
	APIBasePath          string        `mapstructure:"API_BASE_PATH"`
	SwagAPIBasePath      string        `mapstructure:"SWAG_API_BASE_PATH"`
	GlabsAppID           string        `mapstructure:"GLABS_APP_ID"`
	GlabsAppSecret       string        `mapstructure:"GLABS_APP_SECRET"`
	EnableConsoleLogging bool          `mapstructure:"ENABLE_CONSOLE_LOGGING"`
	EnableFileLogging    bool          `mapstructure:"ENABLE_FILE_LOGGING"`
	LogDirectory         string        `mapstructure:"LOG_DIRECTORY"`
	LogFilename          string        `mapstructure:"LOG_FILENAME"`
	LogMaxSize           int           `mapstructure:"LOG_MAX_SIZE"`
	LogMaxBackups        int           `mapstructure:"LOG_MAX_BACKUPS"`
	LogMaxAge            int           `mapstructure:"LOG_MAX_AGE"`
	CronJobs             string        `mapstructure:"CRON_JOBS"`
}

Config store all configuration of the application. Values are read by viper from a config file or environment variables.

func LoadConfig

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

LoadConfig read configuration from file or environment variables.

type Float4

type Float4 struct {
	pgtype.Float4
}

func (Float4) MarshalJSON

func (src Float4) MarshalJSON() ([]byte, error)

MarshalJSON for NullFloat4

func (*Float4) UnmarshalJSON

func (dst *Float4) UnmarshalJSON(b []byte) error

UnmarshalJSON for NullFloat4

type PaginatedList

type PaginatedList[T any] struct {
	Page       int32 `json:"page"`
	PerPage    int32 `json:"per_page"`
	TotalPages int32 `json:"total_pages"`
	NextPage   int32 `json:"next_page"`
	PrevPage   int32 `json:"prev_page"`
	Count      int32 `json:"count"`
	Items      []T   `json:"items"`
}

func NewPaginatedList

func NewPaginatedList[T any](page, limit, count int32, items []T) PaginatedList[T]

type Point

type Point struct {
	*geom.Point
}

func (*Point) Scan

func (p *Point) Scan(src interface{}) error

Scan implements the database/sql Scanner interface.

func (*Point) Value

func (p *Point) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

Jump to

Keyboard shortcuts

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