config

package
v0.0.0-...-534a007 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheLocal *cache.Cache
View Source
var DB *gorm.DB
View Source
var LogFileDir = Conf.LogDir
View Source
var RedisGO *redis.Client

Functions

func NewConfig

func NewConfig(filename string) error

初始化环境变量,先读取 yaml 配置文件,在读取环境变量

Types

type Config

type Config struct {
	LogDir     string      `yaml:"log_dir"`
	LogName    LogName     `yaml:"log_name"`
	Mysql      MysqlConfig `yaml:"mysql"`
	Redis      RedisConfig `yaml:"redis"`
	TokenCache string      `yaml:"token_cache"`
}
var Conf Config

type LogName

type LogName struct {
	StatLogFile        string `yaml:"stat_log_file"`
	ErrorLogFile       string `yaml:"error_log_file"`
	PanicLogFile       string `yaml:"panic_log_file"`
	StderrPanicLogFile string `yaml:"stderr_panic_log_file"`
}

type MysqlConfig

type MysqlConfig struct {
	Dsn      string `yaml:"dsn"`
	Database string `yaml:"database"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Port     string `yaml:"port"`
}

type Option

type Option func(*Config)

func AddMysqlDns

func AddMysqlDns(addr string) Option

func AddMysqlPass

func AddMysqlPass(p string) Option

func AddMysqlUserName

func AddMysqlUserName(u string) Option

type RedisConfig

type RedisConfig struct {
	Hostname string `yaml:"hostname"`
	Port     string `yaml:"port"`
	Database string `yaml:"database"`
}

Jump to

Keyboard shortcuts

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