main.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package main
  2. import (
  3. "eta/eta_docs/core"
  4. "fmt"
  5. "os"
  6. "path/filepath"
  7. "strings"
  8. "sync"
  9. )
  10. // @BasePath /
  11. func main() {
  12. core.RunServe()
  13. }
  14. // 检测指标文件
  15. //
  16. //x:1034
  17. //y:598
  18. func TestFileName(filePath string) {
  19. fmt.Println("filePath:", filePath)
  20. var newFilePath string
  21. defer func() {
  22. //重命名文件
  23. fmt.Println("newFilePath")
  24. fmt.Println(newFilePath)
  25. err := os.Rename(filePath, newFilePath)
  26. if err != nil {
  27. fmt.Println("os.Rename Err:" + err.Error())
  28. }
  29. }()
  30. var runMode string
  31. if strings.Contains(filePath, "debug") {
  32. runMode = "debug"
  33. } else {
  34. runMode = "release"
  35. }
  36. fmt.Println(runMode)
  37. //处理文件名
  38. dir, fp := filepath.Split(filePath)
  39. fmt.Println(dir)
  40. fmt.Println(fp)
  41. frequency := "年"
  42. var wg = sync.WaitGroup{}
  43. wg.Add(1)
  44. go func() {
  45. var frequencyStr string
  46. if strings.Contains(frequency, "日") {
  47. frequencyStr = "day"
  48. } else if strings.Contains(frequency, "周") {
  49. frequencyStr = "week"
  50. } else if strings.Contains(frequency, "月") {
  51. frequencyStr = "month"
  52. } else if strings.Contains(frequency, "年") {
  53. frequencyStr = "year"
  54. }
  55. if !strings.Contains(filePath, frequencyStr) {
  56. fpArr := strings.Split(fp, "_")
  57. for k, v := range fpArr {
  58. if k == 0 {
  59. newFilePath = v + "_" + frequencyStr
  60. } else {
  61. newFilePath = newFilePath + "_" + v
  62. }
  63. }
  64. }
  65. wg.Done()
  66. }()
  67. wg.Wait()
  68. newFilePath = dir + newFilePath
  69. }