From 82d8892b77d1032de0301214ebd537afe3d91622 Mon Sep 17 00:00:00 2001 From: songzhibin97 <49082129+songzhibin97@users.noreply.github.com> Date: Sun, 26 Sep 2021 10:39:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=98=8E=E7=A1=AEroot=E8=AF=AD=E4=B9=89?= =?UTF-8?q?=20(#740)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat:明确root语义 (#740) --- server/config.yaml | 2 ++ server/core/viper.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/config.yaml b/server/config.yaml index 8130f1ed..e2282e3c 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -72,6 +72,8 @@ local: # autocode configuration autocode: transfer-restart: true + # root 自动适配项目根目录 + # 请不要手动配置,他会在项目加载的时候识别出根路径 root: "" server: /server server-api: /api/v1/autocode diff --git a/server/core/viper.go b/server/core/viper.go index ddfdd217..bf0a11a9 100644 --- a/server/core/viper.go +++ b/server/core/viper.go @@ -56,9 +56,11 @@ func Viper(path ...string) *viper.Viper { if err := v.Unmarshal(&global.GVA_CONFIG); err != nil { fmt.Println(err) } + // root 适配性 + // 根据root位置去找到对应迁移位置,保证root路径有效 global.GVA_CONFIG.AutoCode.Root, _ = filepath.Abs("..") global.BlackCache = local_cache.NewCache( local_cache.SetDefaultExpire(time.Second * time.Duration(global.GVA_CONFIG.JWT.ExpiresTime)), - ) + ) return v }