package services import ( "eta/eta_data_analysis/utils" "fmt" "github.com/patrickmn/go-cache" "io/fs" "path/filepath" "time" ) func mtjhWatch() { fmt.Println("mtjhWatch start") var err error defer func() { if err != nil { fmt.Println("mtjhWatch Err:" + err.Error()) } }() var cacheClient *cache.Cache if cacheClient == nil { cacheClient = cache.New(365*24*time.Hour, 365*24*time.Hour) } err = filepath.Walk(utils.MtjhFilePath, func(path string, info fs.FileInfo, err error) error { if err != nil { return err } if !info.IsDir() { /*fileInfo, err := os.Stat(path) if err != nil { fmt.Println("os.Stat:", err.Error()) } winFileAttr := fileInfo.Sys().(*syscall.Win32FileAttributeData) modifyTimeStr := utils.SecondToTime(winFileAttr.LastWriteTime.Nanoseconds() / 1e9).Format(utils.FormatDateTime) existModifyTime, ok := cacheClient.Get(path) if ok { existModifyTimeStr := existModifyTime.(string) if existModifyTimeStr != modifyTimeStr { if strings.Contains(path, "煤炭江湖") { err = Mtjh(path) } } } else { if strings.Contains(path, "煤炭江湖") { err = Mtjh(path) } } cacheClient.Delete(path) cacheClient.Set(path, modifyTimeStr, 24*time.Hour)*/ } return nil }) }