package main import ( "fmt" "log" "strings" "text/template" ) const todayTemplate = `Today's Weather: Conditions: {{range .Weather}} {{.Description}} {{end}} Morning Temp: {{.Temp.Morn}} F, Feels like {{.FeelsLike.Morn}} F Daytime Temp: {{.Temp.Day}} F, Feels like {{.FeelsLike.Day}} F Evening Temp: {{.Temp.Eve}} F, Feels like {{.FeelsLike.Eve}} F LateNight Temp: {{.Temp.Night}} F, Feels like {{.FeelsLike.Night}} F ` func TodayToReport(today Daily) string { var report strings.Builder tmpl, err := template.New("today").Parse(todayTemplate) if err != nil { log.Fatal(err) } if today.Rain > 0 { fmt.Fprintf(&report, "Might rain today (Rain == %v)\n", today.Rain) } if today.WindSpeed > 12.00 { fmt.Fprintf(&report, "Seems pretty windy today (WindSpeed == %v)\n", today.WindSpeed) } if today.Humidity > 80.0 { fmt.Fprintf(&report, "High humidity today! (Humidity == %v)\n", today.Humidity) } if err := tmpl.Execute(&report, today); err != nil { log.Fatal(err) } return report.String() }