package main import ( "fmt" "time" ) func main() { t := time.Now() yday := t.YearDay() fmt.Println(yday) }
package main import ( "fmt" "time" ) func main() { t := time.Date(2022, time.June, 15, 0, 0, 0, 0, time.UTC) yday := t.YearDay() fmt.Println(yday) }In this example, we create a new time using `time.Date()` with the year, month, and day specified. We then retrieve the day of the year using `t.YearDay()`. Finally, we print the day of the year using `fmt.Println()`. Both examples use the "time" package library in Go language.