From aefdb47c32a6845232013e71be3a0b00d6cd2e6b Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 19:06:25 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E2=9C=A8=EF=BC=9A=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=89=A9=E5=B1=95=E9=A1=B9=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/api/server.go | 6 ++++-- config/extent.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 config/extent.go diff --git a/cmd/api/server.go b/cmd/api/server.go index 0b998e4..dde9044 100644 --- a/cmd/api/server.go +++ b/cmd/api/server.go @@ -22,6 +22,7 @@ import ( "go-admin/app/jobs" "go-admin/common/database" "go-admin/common/global" + ext "go-admin/config" ) var ( @@ -50,7 +51,8 @@ func init() { } func setup() { - + // 注入配置扩展项 + config.ExtendConfig = &ext.ExtConfig //1. 读取配置 config.Setup(file.NewSource, file.WithPath(configYml)) go config.Watch() @@ -148,4 +150,4 @@ func run() error { func tip() { usageStr := `欢迎使用 ` + pkg.Green(`go-admin `+global.Version) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令` fmt.Printf("%s \n\n", usageStr) -} +} \ No newline at end of file diff --git a/config/extent.go b/config/extent.go new file mode 100644 index 0000000..e477fbf --- /dev/null +++ b/config/extent.go @@ -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 +} \ No newline at end of file