conf

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IConfBase     *BaseConf
	IConfRedisMap *RedisMapConf
	IConfMySQLMap *MySQLMapConf
)

全局变量

View Source
var (
	IConfEnvPath string //配置文件目录路径
	IConfEnv     string //配置环境名 dev prod
)
View Source
var ViperConfMap map[string]*viper.Viper

Functions

func GetBoolConf

func GetBoolConf(key string) bool

func GetConf

func GetConf(key string) interface{}

func GetConfEnv

func GetConfEnv() string

获取配置环境名称

func GetDurationConf

func GetDurationConf(key string) time.Duration

func GetFloat64Conf

func GetFloat64Conf(key string) float64

func GetIntConf

func GetIntConf(key string) int

func GetStringConf

func GetStringConf(key string) string
 =================================================================
	=============== 最原始的读取配置文件方法 ==============
 * =================================================================

func GetStringMapConf

func GetStringMapConf(key string) map[string]interface{}

func GetStringMapStringConf

func GetStringMapStringConf(key string) map[string]string

func GetStringSliceConf

func GetStringSliceConf(key string) []string

func GetTimeConf

func GetTimeConf(key string) time.Time

func InitBaseConf

func InitBaseConf(path string) error

================================== BaseConf =================================

func InitConfEnv

func InitConfEnv(configDir string) error
 ============================================================================
	====初始化 配置文件环境===
	解析配置文件目录
	eg:config=conf/dev/base.toml 	ConfEnvPath=conf/dev	ConfEnv=dev
 * ============================================================================

func InitMySQLConf

func InitMySQLConf(path string) error

================================== MySQLMapConf 系列=================================

func InitRedisConf

func InitRedisConf(path string) error

================================== RedisConf ================================= 访问案例:lib.IConfRedisMap.List["pro"].ProxyList

func IsSetConf

func IsSetConf(key string) bool

是否设置了key

Types

type BaseConf

type BaseConf struct {
	Base struct {
		DebugMode    string `mapstructure:"debug_mode"`
		TimeLocation string `mapstructure:"time_location"`
	} `mapstructure:"base"`
	Http struct {
		Addr           string `mapstructure:"addr"`
		ReadTimeout    int    `mapstructure:"read_timeout"`
		WriteTimeout   int    `mapstructure:"write_timeout"`
		MaxHeaderBytes int    `mapstructure:"max_header_bytes"`
	} `mapstructure:"ihttp"`
}

type MySQLConf

type MySQLConf struct {
	DriverName      string `mapstructure:"driver_name"`
	DataSourceName  string `mapstructure:"data_source_name"`
	MaxOpenConn     int    `mapstructure:"max_open_conn"`
	MaxIdleConn     int    `mapstructure:"max_idle_conn"`
	ConnMaxLifeTime int    `mapstructure:"conn_max_life_time"`
}

type MySQLMapConf

type MySQLMapConf struct {
	List map[string]*MySQLConf `mapstructure:"list"`
}

type RedisConf

type RedisConf struct {
	ProxyList    []string `mapstructure:"proxy_list"`
	Password     string   `mapstructure:"password"`
	Db           int      `mapstructure:"db"`
	ConnTimeout  int      `mapstructure:"conn_timeout"`
	ReadTimeout  int      `mapstructure:"read_timeout"`
	WriteTimeout int      `mapstructure:"write_timeout"`
}

type RedisMapConf

type RedisMapConf struct {
	List map[string]*RedisConf `mapstructure:"list"`
}

Jump to

Keyboard shortcuts

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