package main import ( "fmt" "time" ) func main() { today := time.Now().Weekday() fmt.Println("Today is", today) }
Today is Wednesday
package main import ( "fmt" "time" ) func main() { today := time.Now().Weekday() if today == time.Saturday || today == time.Sunday { fmt.Println("It's the weekend!") } else { fmt.Println("It's a weekday.") } }
It's a weekday.As mentioned earlier, the Time Weekday struct belongs to the Go Time package library.