ncfg

package
v1.0.1-0...-bd443ad Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNConfigFromFilePathJsonContent

func NewNConfigFromFilePathJsonContent(cfgContentEnvName string) func() *NConfig

func NewNConfigFromTomlFilePathEnv

func NewNConfigFromTomlFilePathEnv(cfgPathEnvName string) func() *NConfig

Types

type AliSms

type AliSms struct {
	Key    string `mapstructure:"key" json:"key" toml:"key"`
	Secret string `mapstructure:"secret" json:"secret" toml:"secret"`
}

type Config

type Config struct {
	Http     Http     `mapstructure:"http" json:"http" toml:"http"`
	Log      Log      `mapstructure:"log" json:"log" toml:"log"`
	DB       DB       `mapstructure:"db" json:"db" toml:"db"`
	FileSave FileSave `mapstructure:"file_save" json:"file_save" toml:"file_save"`
	JWT      JWT      `mapstructure:"jwt" json:"jwt" toml:"jwt"`
	Email    Email    `mapstructure:"email" json:"email" toml:"email"`
	AliSms   AliSms   `mapstructure:"ali_sms" json:"ali_sms" toml:"ali_sms"`
}

type DB

type DB struct {
	ConnStr         string `mapstructure:"conn_str" json:"conn_str" toml:"conn_str"`
	MaxOpenConn     int    `mapstructure:"max_open_conn" json:"max_open_conn" toml:"max_open_conn"`
	MaxIdleConn     int    `mapstructure:"max_idle_conn" json:"max_idle_conn" toml:"max_idle_conn"`
	ConnMaxLeftTime int    `mapstructure:"conn_max_left_time" json:"conn_max_left_time" toml:"conn_max_left_time"` // 秒数
}

DB 数据库相关配置

type Email

type Email struct {
	Address  string `mapstructure:"address" json:"address" toml:"address"`
	Host     string `mapstructure:"host" json:"host" toml:"host"`
	Port     int    `mapstructure:"port" json:"port" toml:"port"`
	UserName string `mapstructure:"user_name" json:"user_name" toml:"user_name"`
	Password string `mapstructure:"password" json:"password" toml:"password"`
}

type FileSave

type FileSave struct {
	OssKey      string `mapstructure:"oss_key" json:"oss_key" toml:"oss_key"`
	OssSecret   string `mapstructure:"oss_secret" json:"oss_secret" toml:"oss_secret"`
	OssEndPoint string `mapstructure:"oss_end_point" json:"oss_end_point" toml:"oss_end_point"`
	OssBucket   string `mapstructure:"oss_bucket" json:"oss_bucket" toml:"oss_bucket"`
	Channel     string `mapstructure:"channel" json:"channel" toml:"channel"` // local qiniu aliyun minio aws
}

type Http

type Http struct {
	EnableSwagger bool   `mapstructure:"enable_swagger" json:"enable_swagger" toml:"enable_swagger"`
	GinMode       string `mapstructure:"gin_mode" json:"gin_mode" toml:"gin_mode"`
	Port          int    `mapstructure:"port" json:"port" toml:"port"`
	SslPri        string `mapstructure:"ssl_pri" json:"ssl_pri" toml:"ssl_pri"`
	SslPub        string `mapstructure:"ssl_pub" json:"ssl_pub" toml:"ssl_pub"`
	Url           string `mapstructure:"url" json:"url" toml:"url"`
}

Http http相关配置

type JWT

type JWT struct {
	NormalExpDuration int    `mapstructure:"normal_exp_duration" json:"normal_exp_duration" toml:"normal_exp_duration"` // 秒
	HS256key          string `mapstructure:"hs_256_key" json:"hs_256_key" toml:"hs256_key"`
}

type Log

type Log struct {
	LogFile  string `mapstructure:"log_file" json:"log_file" toml:"log_file"`    // 配置文件 空为控制台
	LogLevel uint32 `mapstructure:"log_level" json:"log_level" toml:"log_level"` // 0-6 fatal ... trace
}

Log 日志相关配置

type NConfig

type NConfig struct {
	V      *viper.Viper
	RunEnv *run_env.RunEnv
}

func NewNConfig

func NewNConfig() *NConfig

func (*NConfig) GetAliSmsCfg

func (cfg *NConfig) GetAliSmsCfg() *AliSms

func (*NConfig) GetConfigItem

func (cfg *NConfig) GetConfigItem(path string, cfgItem interface{})

func (*NConfig) GetDbCfg

func (cfg *NConfig) GetDbCfg() *DB

func (*NConfig) GetEmailCfg

func (cfg *NConfig) GetEmailCfg() *Email

func (*NConfig) GetFileSaveCfg

func (cfg *NConfig) GetFileSaveCfg() *FileSave

func (*NConfig) GetHttpCfg

func (cfg *NConfig) GetHttpCfg() *Http

func (*NConfig) GetJwtCfg

func (cfg *NConfig) GetJwtCfg() *JWT

func (*NConfig) GetLogCfg

func (cfg *NConfig) GetLogCfg() *Log

func (*NConfig) LoadConfigByFile

func (cfg *NConfig) LoadConfigByFile(name string) error

func (*NConfig) LoadFromConfigJsonStr

func (cfg *NConfig) LoadFromConfigJsonStr(cfgStr string) error

func (*NConfig) LoadFromConfigTomlStr

func (cfg *NConfig) LoadFromConfigTomlStr(cfgStr string) error

Jump to

Keyboard shortcuts

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