config

package
v0.0.0-...-cff51de Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEV  = "dev"
	PROD = "prod"
)

Variables

This section is empty.

Functions

func Load

func Load(conf any, filenames ...string) error

Load 加载配置到conf上,filenames 支持多个配置文件, 对应相同字段,以后者为准,解析过程中遇到错误回直接panic,因此可以忽略返回的错误

Types

type CRMConfig

type CRMConfig struct {
	ServerPort int    `env:"SERVER_PORT"`
	LogLevel   string `env:"LOGGER_LEVEL"`
}

type DbConfig

type DbConfig struct {
	DbUser string `env:"DB_USER"`
	DbPswd string `env:"DB_PASSWORD"`
	DbHost string `env:"DB_HOST"`
	DbPort int    `env:"DB_PORT"`
	DbName string `env:"DB_NAME"`
}

DbConfig 对应 /configs/develop.env配置类型定义

type JWTConfig

type JWTConfig struct {
	Issuer             string        `env:"JWT_ISSUER"`
	SecretKey          string        `env:"JWT_SECRETKEY"`
	AccessToknExpires  time.Duration `env:"JWT_ACCESSTOKEN_EXPIRES"`
	RefreshToknExpires time.Duration `env:"JWT_REFRESHTOKEN_EXPIRES"`
}

type ParserFunc

type ParserFunc = func(v string) (any, error)

type RedisConfig

type RedisConfig struct {
	Host     string `env:"REDIS_HOST"`
	Port     int    `env:"REDIS_PORT"`
	Password string `env:"REDIS_PASSWORD"`
	DB       int    `env:"REDIS_DB"`
}

Jump to

Keyboard shortcuts

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