优化缓存机制 补充错误码

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
}
+11 -1
View File
@@ -67,6 +67,16 @@ func FindPathByBasePath(basefun func() (basePath string, err error), path string
if err != nil {
return "", err
}
path = filepath.Join(filepath.Dir(basePath), path)
info, err := os.Stat(basePath)
if err != nil {
return "", err
}
if !info.IsDir() {
path = filepath.Join(filepath.Dir(basePath), path)
} else {
path = filepath.Join(basePath, path)
}
return path, nil
}