smithery/penitence1992
config-skill
This skill should be used when the user asks to "load", "parse configuration config file", "read properties file", "manage application settings", "switch environment config", "configure application", "?
Use judgment
Installs
0
Stars
—
Security
No audit
Freshness
Unknown
Updated
—
Installation
Project
Global
Entire repo
Entire repo (global)
$
npx skills add smithery/penitence1992 --skill config-skill
Copy
SKILL.md
配置文件管理
.properties 配置文件格式
Name=api-api
Port=31508
Mode=dev
Timeout=30000
# 数据库配置
InternalMysqlReader.Url=user01:password@tcp(192.168.4.14:3306)/odds_center?...
InternalMysqlReader.Debug=true
InternalMysqlReader.MaxOpen=100
InternalMysqlReader.MaxIdle=50
# Redis 配置
RedisConf.Host=192.168.4.7:30679
RedisConf.Pass=123456
RedisConf.Db=9
# RabbitMQ 配置
InternalRabbit.Url=amqp://guest:[email protected] :5672
配置结构体定义
type Config struct {
rest.RestConf
SourceRabbit rabbitmq.RabbitConf `json:",optional"`
InternalRabbit rabbitmq.RabbitConf
InternalMysqlReader cfg.MysqlConf
InternalMysqlWriter cfg.MysqlConf
RedisConf cfg.RedisConf
Pprof cfg.PprofConf `json:",optional"`
AliOss cfg.AliOss
AwsOss cfg.AwsOss
OssType string `json:",optional"`
}
配置加载
// api.go
var configFiles = []string{"api/etc/api.properties"}
flag.Func("f", "the config file", func(s string) error {
configFiles = []string{s}
return nil
})
var c config.Config
if err := cfg.LoadProperties(configFiles, &c); err != nil {
panic(err)
}
MySQL 配置
type MysqlConf struct {
Url string
MaxOpen int `json:",optional"`
MaxIdle int `json:",default=50"`
Debug bool `json:",default=false"`
}
Redis 配置
type RedisConf struct {
Host string
Pass string `json:",optional"`
Tls bool `json:",optional"`
Db int `json:",default=0"`
Node string `json:",default=node,options=node|cluster"`
}
RabbitMQ 配置
type RabbitConf struct {
Url string
}