package main import ( "fmt" "strconv" "testing" "time" ) func TestMonth(T *testing.T) { // 创建2023年12月31日的时间对象 date := time.Date(2023, time.August, 30, 0, 0, 0, 0, time.UTC) next := date.AddDate(0, -1, -1) month := int(next.Month()) monthStr := strconv.Itoa(month) year := next.Year() yearStr := strconv.Itoa(year) //预处理索引名称 PreBiddingIndex := "bidding_" + yearStr + monthStr fmt.Sprintf(PreBiddingIndex) }