From 8bbd49554f6df0b9b6e0eacbe8d0eb9ba9f839bf Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 17 Jul 2023 18:43:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E8=BF=87=20golang=20=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E7=94=9F=E6=88=90=E7=9A=84=E9=85=8D=E7=BD=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BB=A3=E7=A0=81=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=20Sync=20=E5=87=BD=E6=95=B0=E6=89=A7=E8=A1=8C=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E7=9A=84=E9=85=8D=E7=BD=AE=E6=93=8D=E4=BD=9C=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=85=8D=E7=BD=AE=E8=A2=AB=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=80=A0=E6=88=90=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- planner/pce/tmpls/golang.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/planner/pce/tmpls/golang.go b/planner/pce/tmpls/golang.go index f7afb2b..6d0f400 100644 --- a/planner/pce/tmpls/golang.go +++ b/planner/pce/tmpls/golang.go @@ -27,6 +27,7 @@ func (slf *Golang) Render(templates ...*pce.TmplStruct) (string, error) { import ( jsonIter "github.com/json-iterator/go" "github.com/kercylan98/minotaur/utils/log" + "github.com/kercylan98/minotaur/utils/hash" "sync" ) @@ -192,13 +193,22 @@ func (slf *Golang) Render(templates ...*pce.TmplStruct) (string, error) { // GetConfigs 获取所有配置 func GetConfigs() map[Sign]any { - return configs + mutex.Lock() + defer mutex.Unlock() + return hash.Copy(configs) } // GetConfigSigns 获取所有配置的标识 func GetConfigSigns() []Sign { return signs } + + // Sync 同步操作配置 + func Sync(handle func(configs map[Sign]any)) { + mutex.Lock() + defer mutex.Unlock() + handle(hash.Copy(configs)) + } `, slf) }