优化缓存机制 补充错误码

This commit is contained in:
2025-10-09 02:04:32 +08:00
parent 73480005eb
commit 84899f9935
10 changed files with 596 additions and 28 deletions
+14
View File
@@ -0,0 +1,14 @@
package zm_lib
import (
"complie-erlang/cache"
"fmt"
"github.com/spf13/cobra"
)
func PersistentFlagsStringVar(cmd *cobra.Command, varK *string, cache cache.Cache, globalKey string, defaultValue string, desc string) error {
pluginKey := fmt.Sprintf("%s.%s", cmd.Use, globalKey)
plugin, err := cache.GetDefault(pluginKey, defaultValue)
cmd.PersistentFlags().StringVar(varK, globalKey, plugin.(string), fmt.Sprintf("%s (global.key:\"%s\")", desc, pluginKey))
return err
}