package main import ( "eta/eta_docs/core" "fmt" "os" "path/filepath" "strings" "sync" ) // @BasePath / func main() { core.RunServe() } // 检测指标文件 // //x:1034 //y:598 func TestFileName(filePath string) { fmt.Println("filePath:", filePath) var newFilePath string defer func() { //重命名文件 fmt.Println("newFilePath") fmt.Println(newFilePath) err := os.Rename(filePath, newFilePath) if err != nil { fmt.Println("os.Rename Err:" + err.Error()) } }() var runMode string if strings.Contains(filePath, "debug") { runMode = "debug" } else { runMode = "release" } fmt.Println(runMode) //处理文件名 dir, fp := filepath.Split(filePath) fmt.Println(dir) fmt.Println(fp) frequency := "年" var wg = sync.WaitGroup{} wg.Add(1) go func() { var frequencyStr string if strings.Contains(frequency, "日") { frequencyStr = "day" } else if strings.Contains(frequency, "周") { frequencyStr = "week" } else if strings.Contains(frequency, "月") { frequencyStr = "month" } else if strings.Contains(frequency, "年") { frequencyStr = "year" } if !strings.Contains(filePath, frequencyStr) { fpArr := strings.Split(fp, "_") for k, v := range fpArr { if k == 0 { newFilePath = v + "_" + frequencyStr } else { newFilePath = newFilePath + "_" + v } } } wg.Done() }() wg.Wait() newFilePath = dir + newFilePath }