我尝试了不同的策略,但无济于事。中的以下代码显示了声明但未用于 的变量,以及当它们在强制转换中使用时(最后 3 行代码):vscodeyearmonthday
var year, month, day int
year = -1
month = -1
day = -1
// Calculate Year Month Day
if eventCalendar == "gregorian" {
s := strings.Split("eventDate", "/")
year, err := strconv.Atoi(s[0])
if err != nil {
log.Fatal("Cannot convert year to integer: " + s[0] + ". " + err.Error())
}
month, err := strconv.Atoi(s[1])
if err != nil {
log.Fatal("Cannot convert month to integer: " + s[1] + ". " + err.Error())
}
day, err := strconv.Atoi(s[2])
if err != nil {
log.Fatal("Cannot convert day to integer: " + s[2] + ". " + err.Error())
}
} else if eventCalendar == "jalali" {
s := strings.Split("eventDate", "-")
year, err := strconv.Atoi(s[0])
if err != nil {
log.Fatal("Cannot convert year to integer: " + s[0] + ". " + err.Error())
}
month, err := strconv.Atoi(s[1])
if err != nil {
log.Fatal("Cannot convert month to integer: " + s[1] + ". " + err.Error())
}
day, err := strconv.Atoi(s[2])
if err != nil {
log.Fatal("Cannot convert day to integer: " + s[2] + ". " + err.Error())
}
// TODO: Convert to gregorian
} else {
panic("Unknown calendar type: eventcalendar")
}
strYear := strconv.Itoa(year)
strMonth := strconv.Itoa(month)
strDay := strconv.Itoa(day)
// ...其余代码
慕仙森
相关分类