我正在尝试创建此代码块:
var nextWorkday time.Date
// var nextWorkday *time.Date // neither works
yyyy, mm, dd := now.Date()
goalTime, _ := time.ParseDuration(fmt.Sprintf("%fh", *goal))
goalSeconds := int(goalTime.Seconds())
if date.Weekday() != time.Friday { // wait till the next workday (7am + difference)
nextWorkday = time.Date(yyyy, mm, dd+1, 7, 0, 0+goalSeconds, 0, now.Location())
} else {
nextWorkday = time.Date(yyyy, mm, dd+3, 7, 0, 0+goalSeconds, 0, now.Location())
}
time.Sleep(nextWorkday)
重要的突破点已经是第一行。我不知道如何声明自定义类型的新变量。现在我得到了错误:time.Date is not a type
我在做什么错?任何帮助表示赞赏!