?Go???,??????????????????????Go?time
?????????????????,????????????Go???????:
package main
import (
"fmt"
"time"
)
func isLeapYear(year int) bool {
return year%4 == 0 && (year0 != 0 || year@0 == 0)
}
func main() {
year := 2020
if isLeapYear(year) {
fmt.Printf("%d ???\n", year)
} else {
fmt.Printf("%d ????\n", year)
}
// ??????
now := time.Now()
currentYear := now.Year()
// ???????????
if isLeapYear(currentYear) {
fmt.Printf("%d ???\n", currentYear)
} else {
fmt.Printf("%d ????\n", currentYear)
}
}
??????,?????????isLeapYear
???,???????????year
,????????,???????????????????????????????:??4??????100??,????400???
?main
???,???????????(??2020?)?????,??????????????????????time.Now()
????????,???now.Year()
???????