default_test.go 491 B

12345678910111213141516171819202122
  1. package main
  2. import (
  3. "fmt"
  4. "testing"
  5. "time"
  6. )
  7. // 测试函数
  8. func TestBeego(t *testing.T) {
  9. generateMonthList(time.Now().AddDate(-1, 0, 0))
  10. }
  11. func generateMonthList(startMonth time.Time) []string {
  12. var months []string
  13. endMonth := time.Now().AddDate(0, 1, 0)
  14. for month := startMonth; month.Before(endMonth); month = month.AddDate(0, 1, 0) {
  15. fmt.Println("=========================", month.Format("2006-01"))
  16. months = append(months, month.Format("2006-01"))
  17. }
  18. return months
  19. }