feat ✨: 配置文件扩展项使用
This commit is contained in:
1 parent
30feaae7e7
commit
aefdb47c32
2 files changed
+19
-1
No files matched your search
+3
-1
@@ -22,6 +22,7 @@ import (
|
|||||||
"go-admin/app/jobs"
|
"go-admin/app/jobs"
|
||||||
"go-admin/common/database"
|
"go-admin/common/database"
|
||||||
"go-admin/common/global"
|
"go-admin/common/global"
|
||||||
|
ext "go-admin/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -50,7 +51,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setup() {
|
func setup() {
|
||||||
|
// 注入配置扩展项
|
||||||
|
config.ExtendConfig = &ext.ExtConfig
|
||||||
//1. 读取配置
|
//1. 读取配置
|
||||||
config.Setup(file.NewSource, file.WithPath(configYml))
|
config.Setup(file.NewSource, file.WithPath(configYml))
|
||||||
go config.Watch()
|
go config.Watch()
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
var ExtConfig Extand
|
||||||
|
|
||||||
|
// 扩展配置
|
||||||
|
// extend:
|
||||||
|
// demo:
|
||||||
|
// name: demo-name
|
||||||
|
// 使用方法: config.ExtConfig......即可!!
|
||||||
|
type Extand struct {
|
||||||
|
// Demo Demo // 这里配置对应配置文件的结构即可
|
||||||
|
}
|
||||||
|
|
||||||
|
type Demo struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
Reference in new issue
Block a user