优化缓存机制 补充错误码
This commit is contained in:
+19
@@ -1,11 +1,30 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"complie-erlang/cache"
|
||||
"complie-erlang/parser/zm_lib"
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
// 全局缓存
|
||||
var globalCache = InitGlobalCache()
|
||||
|
||||
const globalCacheFileName = "global.json"
|
||||
|
||||
func InitGlobalCache() cache.Cache {
|
||||
pathByExecutable, err := zm_lib.FindPathByExecutable(globalCacheFileName)
|
||||
if err != nil {
|
||||
panic("未查找到根目录 Err:" + err.Error())
|
||||
}
|
||||
newCache, err := cache.NewCache(pathByExecutable)
|
||||
if err != nil {
|
||||
panic("创建缓存失败 Err:" + err.Error())
|
||||
}
|
||||
return newCache
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "",
|
||||
Short: "erlang注解生成配置模版工具",
|
||||
|
||||
Reference in New Issue
Block a user