From ebcf2be1799e5107563baed6145e9d6148100da7 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Thu, 17 Nov 2022 08:31:33 +0800 Subject: [PATCH] add CfgBe/CfgNot function to conf package --- internal/conf/conf.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/internal/conf/conf.go b/internal/conf/conf.go index b2498ef5..ebc471fd 100644 --- a/internal/conf/conf.go +++ b/internal/conf/conf.go @@ -112,13 +112,33 @@ func Cfg(key string) (string, bool) { } // CfgIf check expression is true. if expression just have a string like -// `Sms` is mean `Sms` whether define in suite feature settings. expression like +// `Sms` is mean `Sms` whether defined in suite feature settings. expression like // `Sms = SmsJuhe` is mean whether `Sms` define in suite feature settings and value // is `SmsJuhe` func CfgIf(expression string) bool { return features.CfgIf(expression) } +// CfgBe check expression is true then do the handle. if expression just have a string like +// `Sms` is mean `Sms` whether defined in suite feature settings. expression like +// `Sms = SmsJuhe` is mean whether `Sms` define in suite feature settings and value +// is `SmsJuhe` +func CfgBe(expression string, handle func()) { + if features.CfgIf(expression) { + handle() + } +} + +// CfgNot check expression is not true then do the handle. if expression just have a string like +// `Sms` is mean `Sms` whether defined in suite feature settings. expression like +// `Sms = SmsJuhe` is mean whether `Sms` define in suite feature settings and value +// is `SmsJuhe` +func CfgNot(expression string, handle func()) { + if !features.CfgIf(expression) { + handle() + } +} + func GetOssDomain() string { uri := "https://" if CfgIf("AliOSS") {