How to Get the Day of the Week in Go

Get the current day of the week in Go using the time.Now().Weekday() method.

Use the time.Weekday method on a time.Time value to get the day of the week.

import "time"

day := time.Now().Weekday()
fmt.Println(day) // e.g., Monday

The Weekday() method returns a time.Weekday constant (e.g., time.Sunday, time.Monday) which can be compared directly or converted to a string using String().