Documentation ¶
Index ¶
- Constants
- Variables
- func Init() error
- func InitEnvConfig() (map[string]interface{}, error)
- func InitFileConfig() (map[string]interface{}, error)
- func InitFlagConfig() (map[string]interface{}, error)
- func SetFileConfig(fileName string, filePaths []string) (map[string]interface{}, error)
- func VerifyConfig(conf ConfigType) (bool, *gojsonschema.Result)
- type ConfigType
Constants ¶
View Source
const Schema = `` /* 791-byte string literal not displayed */
Schema 默认的配置样式
Variables ¶
View Source
var Config = ConfigType{}
Config 程序的配置
View Source
var DefaultConfig = map[string]interface{}{
"ADDRESS": "0.0.0.0:5000",
"PRIVATE_KEY_PATH": "autogen_rsa.pem",
"PUBLIC_KEY_PATH": "autogen_rsa_pub.pem",
"HASH_KEY": "secret can not guess",
"COMPONENT_NAME": "jwt-center",
"LOG_LEVEL": "DEBUG",
"REGIST_ETCD_URLS": "",
"REGIST_VERSION": "",
"REGIST_ADDRESS": "",
}
DefaultConfig 默认配置
Functions ¶
func InitEnvConfig ¶
InitEnvConfig 从环境变量获得的配置内容初始化配置
func InitFileConfig ¶
InitFileConfig 从默认的配置文件位置读取配置
func SetFileConfig ¶
SetFileConfig 从指定的配置文件中读取配置
func VerifyConfig ¶
func VerifyConfig(conf ConfigType) (bool, *gojsonschema.Result)
VerifyConfig 验证config是否符合要求
Types ¶
type ConfigType ¶
type ConfigType struct { Address string `json:"ADDRESS"` PrivateKeyPath string `json:"PRIVATE_KEY_PATH"` PublicKeyPath string `json:"PUBLIC_KEY_PATH"` Hashkey string `json:"HASH_KEY"` ComponentName string `json:"COMPONENT_NAME"` LogLevel string `json:"LOG_LEVEL"` RegistEtcdURLS string `json:"REGIST_ETCD_URLS"` RegistVersion string `json:"REGIST_VERSION"` RegistAddress string `json:"REGIST_ADDRESS"` }
ConfigType 配置类型
Click to show internal directories.
Click to hide internal directories.