// For more tutorials: https://blog.learngoprogramming.com // // Copyright © 2018 Inanc Gumus // Learn Go Programming Course // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ // package main import ( "fmt" "os" "strconv" ) func main() { if len(os.Args) != 2 { fmt.Println("Give me a year number") return } year, err := strconv.Atoi(os.Args[1]) if err != nil { fmt.Printf("%q is not a valid year.\n", os.Args[1]) return } if year%4 == 0 && (year%100 != 0 || year%400 == 0) { fmt.Printf("%d is a leap year.\n", year) } else { fmt.Printf("%d is not a leap year.\n", year) } } // Review the original source code here: // https://github.com/golang/go/blob/ad644d2e86bab85787879d41c2d2aebbd7c57db8/src/time/time.go#L1289