Documentation
¶
Index ¶
- func GetBool(key string) bool
- func GetDuration(key string) time.Duration
- func GetFloat64(key string) float64
- func GetInt(key string) int
- func GetString(key string) string
- func GetStringMap(key string) map[string]any
- func GetStringMapString(key string) map[string]string
- func GetStringSlice(key string) []string
- func GetViper() *viper.Viper
- func Init() *viper.Viper
- func InitConfig()
- func IsSet(key string) bool
- func SetViper(viperInstance *viper.Viper)
- func Unmarshal(rawVal any) error
- func UnmarshalKey(key string, rawVal any) error
- type Aliyun
- type Auth
- type Cache
- type Config
- type DB
- type Elasticsearch
- type Email
- type Jwt
- type LogConfig
- type Milvus
- type Mysql
- func (m *Mysql) GetDatabase() string
- func (m *Mysql) GetHost() string
- func (m *Mysql) GetLog() *MysqlLog
- func (m *Mysql) GetMaxIdleConns() int
- func (m *Mysql) GetMaxOpenConns() int
- func (m *Mysql) GetPassword() string
- func (m *Mysql) GetPingTimeout() time.Duration
- func (m *Mysql) GetPort() int
- func (m *Mysql) GetUser() string
- type MysqlLog
- type Pay
- type Postgres
- func (p *Postgres) GetDatabase() string
- func (p *Postgres) GetHost() string
- func (p *Postgres) GetLog() *PostgresLog
- func (p *Postgres) GetMaxIdleConns() int
- func (p *Postgres) GetMaxOpenConns() int
- func (p *Postgres) GetPassword() string
- func (p *Postgres) GetPingTimeout() time.Duration
- func (p *Postgres) GetPort() int
- func (p *Postgres) GetSSLMode() string
- func (p *Postgres) GetUser() string
- type PostgresLog
- type Qiniu
- type Redis
- type Server
- type Skill
- type Upload
- type Wx
- type WxPay
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDuration ¶
GetDuration 获取指定 key 的 Duration 配置值,支持自定义配置
func GetStringMap ¶
GetStringMap 获取指定 key 的 map 配置值,支持自定义配置
func GetStringMapString ¶
GetStringMapString 获取指定 key 的 map[string]string 配置值,支持自定义配置
func GetStringSlice ¶
GetStringSlice 获取指定 key 的字符串切片配置值,支持自定义配置
func InitConfig ¶
func InitConfig()
func UnmarshalKey ¶
UnmarshalKey 将指定 key 的配置反序列化到用户自定义结构体 例如: config.UnmarshalKey("myapp", &myConfig)
Types ¶
type Aliyun ¶
type Aliyun struct {
AccessKeyID *string `mapstructure:"accessKeyId"`
AccessKeySecret *string `mapstructure:"accessKeySecret"`
Endpoint *string `mapstructure:"endpoint"`
Bucket *string `mapstructure:"bucket"`
}
Aliyun 阿里云配置
func (*Aliyun) GetAccessKeyID ¶
func (*Aliyun) GetAccessKeySecret ¶
func (*Aliyun) GetEndpoint ¶
type Auth ¶
type Auth struct {
IsAuth *bool `mapstructure:"isAuth"`
Ignores []string `mapstructure:"ignores"`
NeedLogins []string `mapstructure:"needLogins"`
}
func (*Auth) GetIgnores ¶
type Cache ¶
type Cache struct {
NeedCache []string `mapstructure:"needCache"`
Expire *int64 `mapstructure:"expire"` //单位秒
}
func (*Cache) GetNeedCache ¶
type Config ¶
type Config struct {
Pay *Pay `mapstructure:"pay"`
Server *Server `mapstructure:"server"`
Cache *Cache `mapstructure:"cache"`
Upload *Upload `mapstructure:"upload"`
Qiniu *Qiniu `mapstructure:"qiniu"`
Aliyun *Aliyun `mapstructure:"aliyun"`
DB *DB `mapstructure:"db"`
Auth *Auth `mapstructure:"auth"`
Wx *Wx `mapstructure:"wx"`
Jwt *Jwt `mapstructure:"jwt"`
Email *Email `mapstructure:"email"`
Log *LogConfig `mapstructure:"log"`
Elasticsearch *Elasticsearch `mapstructure:"elasticsearch"`
Milvus *Milvus `mapstructure:"milvus"`
Skill *Skill `mapstructure:"skill"`
}
type Elasticsearch ¶
type Elasticsearch struct {
Addresses []string `mapstructure:"addresses"`
Username *string `mapstructure:"username"`
Password *string `mapstructure:"password"`
APIKey *string `mapstructure:"apiKey"`
}
Elasticsearch 配置结构体
func (*Elasticsearch) GetAPIKey ¶
func (e *Elasticsearch) GetAPIKey() string
GetAPIKey 获取 ES API Key
func (*Elasticsearch) GetAddresses ¶
func (e *Elasticsearch) GetAddresses() []string
GetAddresses 获取 ES 地址列表
func (*Elasticsearch) GetPassword ¶
func (e *Elasticsearch) GetPassword() string
GetPassword 获取 ES 密码
func (*Elasticsearch) GetUsername ¶
func (e *Elasticsearch) GetUsername() string
GetUsername 获取 ES 用户名
type Email ¶
type Email struct {
Host *string `mapstructure:"host"`
Port *int `mapstructure:"port"`
Username *string `mapstructure:"username"`
Password *string `mapstructure:"password"`
Identity *string `mapstructure:"identity"`
From *string `mapstructure:"from"`
BaseURL *string `mapstructure:"baseUrl"`
}
func (*Email) GetBaseURL ¶
func (*Email) GetIdentity ¶
func (*Email) GetPassword ¶
func (*Email) GetUsername ¶
type Jwt ¶
type Jwt struct {
Secret *string `mapstructure:"secret"`
Expire *time.Duration `mapstructure:"expire"`
Refresh *time.Duration `mapstructure:"refresh"`
}
func (*Jwt) GetRefresh ¶
type LogConfig ¶
type LogConfig struct {
Level *string `mapstructure:"level"`
Format *string `mapstructure:"format"`
AddSource *bool `mapstructure:"addSource"`
Filename *string `mapstructure:"filename"`
MaxSize *int `mapstructure:"maxSize"`
MaxAge *int `mapstructure:"maxAge"`
MaxBackups *int `mapstructure:"maxBackups"`
Output io.Writer `mapstructure:"output"`
}
func (*LogConfig) GetAddSource ¶
func (*LogConfig) GetFilename ¶
func (*LogConfig) GetMaxBackups ¶
func (*LogConfig) GetMaxSize ¶
type Milvus ¶
type Milvus struct {
Address *string `mapstructure:"address"`
DBName *string `mapstructure:"dbName"`
Username *string `mapstructure:"username"`
Password *string `mapstructure:"password"`
}
Milvus 配置结构体
type Mysql ¶
type Mysql struct {
Host *string `mapstructure:"host"`
Port *int `mapstructure:"port"`
User *string `mapstructure:"user"`
Password *string `mapstructure:"password"`
Database *string `mapstructure:"database"`
MaxIdleConns *int `mapstructure:"maxIdleConns"`
PingTimeout *time.Duration `mapstructure:"pingTimeout"`
MaxOpenConns *int `mapstructure:"maxOpenConns"`
Log *MysqlLog `mapstructure:"log"`
}
func (*Mysql) GetDatabase ¶
func (*Mysql) GetMaxIdleConns ¶
func (*Mysql) GetMaxOpenConns ¶
func (*Mysql) GetPassword ¶
func (*Mysql) GetPingTimeout ¶
type MysqlLog ¶
type MysqlLog struct {
SlowThreshold *time.Duration `mapstructure:"slowThreshold"`
LogLevel *string `mapstructure:"level"`
IgnoreRecordNotFoundError *bool `mapstructure:"ignoreRecordNotFoundError"`
ParameterizedQueries *bool `mapstructure:"parameterizedQueries"`
Colorful *bool `mapstructure:"colorful"`
}
func (*MysqlLog) GetColorful ¶
func (*MysqlLog) GetIgnoreRecordNotFoundError ¶
func (*MysqlLog) GetLogLevel ¶
func (*MysqlLog) GetParameterizedQueries ¶
func (*MysqlLog) GetSlowThreshold ¶
type Postgres ¶
type Postgres struct {
Host *string `mapstructure:"host"`
Port *int `mapstructure:"port"`
User *string `mapstructure:"user"`
Password *string `mapstructure:"password"`
Database *string `mapstructure:"database"`
SSLMode *string `mapstructure:"sslmode"`
MaxIdleConns *int `mapstructure:"maxIdleConns"`
PingTimeout *time.Duration `mapstructure:"pingTimeout"`
MaxOpenConns *int `mapstructure:"maxOpenConns"`
Log *PostgresLog `mapstructure:"log"`
}
func (*Postgres) GetDatabase ¶
func (*Postgres) GetLog ¶
func (p *Postgres) GetLog() *PostgresLog
func (*Postgres) GetMaxIdleConns ¶
func (*Postgres) GetMaxOpenConns ¶
func (*Postgres) GetPassword ¶
func (*Postgres) GetPingTimeout ¶
func (*Postgres) GetSSLMode ¶
type PostgresLog ¶
type PostgresLog struct {
SlowThreshold *time.Duration `mapstructure:"slowThreshold"`
LogLevel *string `mapstructure:"level"`
IgnoreRecordNotFoundError *bool `mapstructure:"ignoreRecordNotFoundError"`
ParameterizedQueries *bool `mapstructure:"parameterizedQueries"`
Colorful *bool `mapstructure:"colorful"`
}
func (*PostgresLog) GetColorful ¶
func (pl *PostgresLog) GetColorful() bool
func (*PostgresLog) GetIgnoreRecordNotFoundError ¶
func (pl *PostgresLog) GetIgnoreRecordNotFoundError() bool
func (*PostgresLog) GetLogLevel ¶
func (pl *PostgresLog) GetLogLevel() logger.LogLevel
func (*PostgresLog) GetParameterizedQueries ¶
func (pl *PostgresLog) GetParameterizedQueries() bool
func (*PostgresLog) GetSlowThreshold ¶
func (pl *PostgresLog) GetSlowThreshold() time.Duration
type Redis ¶
type Redis struct {
Addr *string `mapstructure:"addr"`
Password *string `mapstructure:"password"`
DB *int `mapstructure:"db"`
PoolSize *int `mapstructure:"poolSize"`
IdleTimeout *int `mapstructure:"idleTimeout"`
MaxOpenConns *int `mapstructure:"maxOpenConns"`
MaxIdleConns *int `mapstructure:"maxIdleConns"`
}
func (*Redis) GetMaxIdleConns ¶
func (*Redis) GetMaxOpenConns ¶
func (*Redis) GetPassword ¶
func (*Redis) GetPoolSize ¶
type Server ¶
type Server struct {
Port *int `mapstructure:"port"`
Cros []string `mapstructure:"cros"`
AllowOrigins []string `mapstructure:"allowOrigins"`
Mode *string `mapstructure:"mode"`
Name *string `mapstructure:"name"`
Version *string `mapstructure:"version"`
Host *string `mapstructure:"host"`
ReadTimeout *time.Duration `mapstructure:"readTimeout"`
WriteTimeout *time.Duration `mapstructure:"writeTimeout"`
}
func (*Server) GetReadTimeout ¶
func (*Server) GetWriteTimeout ¶
type Skill ¶
type Skill struct {
BaseDir *string `mapstructure:"baseDir"`
}
func (*Skill) GetBaseDir ¶
type WxPay ¶
type WxPay struct {
AppId *string `mapstructure:"appId"`
MchId *string `mapstructure:"mchId"` //商户证书的证书序列号
MchSerialNo *string `mapstructure:"mchSerialNo"` //商户证书的证书序列号
ApiV3Key *string `mapstructure:"apiV3Key"` //apiV3Key,商户平台获取
PrivateKey *string `mapstructure:"privateKey"` //私钥 apiclient_key.pem 读取后的内容
AppSecret *string `mapstructure:"appSecret"`
NotifyUrl *string `mapstructure:"notifyUrl"`
MchCertPath *string `mapstructure:"mchCertPath"`
MchKeyPath *string `mapstructure:"mchKeyPath"`
}
func (*WxPay) GetNotifyUrl ¶
Click to show internal directories.
Click to hide internal directories.