1 Star 0 Fork 0

ichub / gomini

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
di_utils.go 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
leijmdas 提交于 2024-05-14 09:55 . add
package diutils
import (
"gitee.com/ichub/goconfig/common/base/basedto"
"gitee.com/ichub/goconfig/common/base/baseutils/fileutils"
"gitee.com/ichub/goconfig/common/ichubconfig"
)
func FindKey(key string) bool {
return FindBeanDiUtils().FindKey(key)
}
const ini_di_key = "di"
const ini_di_gen = "generate"
const di_define_file = "/config/di/di_define.ini"
type DiUtils struct {
basedto.BaseEntitySingle
rootdir string
ini *ichubconfig.IchubConfigIni `json:"-"`
//key struct ->bool
Items map[string]string
Rerun map[string]string
}
func NewDiUtils() *DiUtils {
var u = &DiUtils{
rootdir: fileutils.FindRootDir(),
ini: ichubconfig.NewIchubConfigIni(),
}
u.init()
return u
}
func (u *DiUtils) init() {
u.LoadConfig()
}
func (this *DiUtils) FindKey(key string) bool {
b, ok := this.Items[key]
return b == "true" || ok
}
/*
#auto init generate
[generate]
rerun = true
#重新生成
[di]
IchubConfig = true
SingleEntity = true
*/
func (this *DiUtils) LoadConfig() {
var filename = this.rootdir + "/" + di_define_file
if !fileutils.TryFileExist(filename) {
filename = fileutils.FindRootPkg() + "/" + di_define_file
}
this.ini.Load(filename)
this.Items = this.ini.FindMap(ini_di_key)
this.Rerun = this.ini.FindMap(ini_di_gen)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ichub/gomini.git
git@gitee.com:ichub/gomini.git
ichub
gomini
gomini
746a50be668d

搜索帮助

344bd9b3 5694891 D2dac590 5694891