diff --git a/internal/view/v1/api.go b/internal/view/v1/api.go index f39ac08..ffa3739 100644 --- a/internal/view/v1/api.go +++ b/internal/view/v1/api.go @@ -60,8 +60,11 @@ type resp struct { } `json:"data"` } -func getDataFromAPI() (ret resp) { - var params []string +func getDataFromAPI() resp { + var ( + ret resp + params []string + ) if len(config.APIKey) == 0 { log.Fatal("No API key specified. Setup instructions are in the README.") @@ -118,7 +121,7 @@ func getDataFromAPI() (ret resp) { } } - return + return ret } func unmarshalLang(body []byte, r *resp) error { diff --git a/internal/view/v1/format.go b/internal/view/v1/format.go index 5c83b85..e9db3a7 100644 --- a/internal/view/v1/format.go +++ b/internal/view/v1/format.go @@ -167,6 +167,7 @@ func formatTemp(c cond) string { unitTemp[config.Imperial]), 15) } + return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15) } @@ -247,7 +248,7 @@ func formatVisibility(c cond) string { } func formatRain(c cond) string { - rainUnit := float32(c.PrecipMM) + rainUnit := c.PrecipMM if config.Imperial { rainUnit = c.PrecipMM * 0.039 } @@ -262,8 +263,12 @@ func formatRain(c cond) string { return pad(fmt.Sprintf("%.1f %s", rainUnit, unitRain(config.Imperial, config.Lang)), 15) } -func formatCond(cur []string, c cond, current bool) (ret []string) { - var icon []string +func formatCond(cur []string, c cond, current bool) []string { + var ( + ret []string + icon []string + ) + if i, ok := codes[c.WeatherCode]; !ok { icon = getIcon("iconUnknown") } else { @@ -344,7 +349,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) { fmt.Sprintf("%v %v %v", cur[4], icon[4], formatRain(c))) } - return + return ret } func justifyCenter(s string, width int) string { @@ -371,7 +376,8 @@ func reverse(s string) string { return string(r) } -func pad(s string, mustLen int) (ret string) { +func pad(s string, mustLen int) string { + var ret string ret = s realLen := utf8.RuneCountInString(ansiEsc.ReplaceAllLiteralString(s, "")) delta := mustLen - realLen @@ -392,5 +398,5 @@ func pad(s string, mustLen int) (ret string) { } } - return + return ret } diff --git a/internal/view/v1/locale.go b/internal/view/v1/locale.go index 04267ca..4369a31 100644 --- a/internal/view/v1/locale.go +++ b/internal/view/v1/locale.go @@ -148,6 +148,7 @@ var ( "mg": "Vinavina toetr'andro hoan'ny:", } + //nolint:misspell daytimeTranslation = map[string][]string{ "af": {"Oggend", "Middag", "Vroegaand", "Laatnag"}, "am": {"ጠዋት", "ከሰዓት በኋላ", "ምሽት", "ሌሊት"}, diff --git a/internal/view/v1/view1.go b/internal/view/v1/view1.go index 3d352b6..4db2f82 100644 --- a/internal/view/v1/view1.go +++ b/internal/view/v1/view1.go @@ -9,8 +9,9 @@ import ( var slotTimes = [slotcount]int{9 * 60, 12 * 60, 18 * 60, 22 * 60} -func printDay(w weather) (ret []string) { +func printDay(w weather) []string { var ( + ret []string dateName string names string )