config

package
v0.0.0-...-887dbeb Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	BaseURL          string        `mapstructure:"base_url"`
	DefaultDuration  time.Duration `mapstructure:"default_duration"`
	SyncViewDuration time.Duration `mapstructure:"sync_view_duration"`
}

type Config

type Config struct {
	Database  DatabaseConfig  `mapstructure:"database"`
	Redis     RedisConfig     `mapstructure:"redis"`
	Server    ServerConfig    `mapstructure:"server"`
	App       AppConfig       `mapstructure:"app"`
	ShortCode ShortCodeConfig `mapstructure:"shortcode"`
	Logger    LogConfig       `mapstructure:"logger"`
	Email     EmailConfig     `mapstructure:"email"`
	JWT       JWTConfig       `mapstructure:"jwt"`
	RandNum   RandNumConfig   `mapstructure:"rand_num"`
}
var Cfg *Config

func NewConfig

func NewConfig(filePath string) (*Config, error)

type DatabaseConfig

type DatabaseConfig struct {
	Driver       string `mapstructure:"driver"`
	Host         string `mapstructure:"host"`
	Port         int    `mapstructure:"port"`
	User         string `mapstructure:"user"`
	Password     string `mapstructure:"password"`
	DBName       string `mapstructure:"dbname"`
	SSLMode      string `mapstructure:"ssl_mode"`
	MaxIdleConns int    `mapstructure:"max_idle_conns"`
	MaxOpenConns int    `mapstructure:"max_open_conns"`
}

func (DatabaseConfig) DSN

func (d DatabaseConfig) DSN() string

type EmailConfig

type EmailConfig struct {
	Password    string `mapstructure:"password"`
	Username    string `mapstructure:"username"`
	HostAddress string `mapstructure:"host_address"`
	HostPort    string `mapstructure:"host_port"`
	Subject     string `mapstructure:"subject"`
	TestMail    string `mapstructure:"test_mail"`
}

type JWTConfig

type JWTConfig struct {
	Secret   string        `mapstructure:"secret"`
	Duration time.Duration `mapstructure:"duration"`
}

type LogConfig

type LogConfig struct {
	Level string `mapstructure:"level"`
}

type RandNumConfig

type RandNumConfig struct {
	Length int `mapstructure:"length"`
}

type RedisConfig

type RedisConfig struct {
	Address           string        `mapstructure:"address"`
	Password          string        `mapstructure:"password"`
	DB                int           `mapstructure:"db"`
	UrlDuration       time.Duration `mapstructure:"url_duration"`
	EmailCodeDuration time.Duration `mapstructure:"email_code_duration"`
}

type ServerConfig

type ServerConfig struct {
	Addr         string        `mapstructure:"addr"`
	WriteTimeout time.Duration `mapstructure:"write_timeout"`
	ReadTimeout  time.Duration `mapstructure:"read_timeout"`
}

type ShortCodeConfig

type ShortCodeConfig struct {
	Length int `mapstructure:"length"`
}

Jump to

Keyboard shortcuts

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