breto

A status bar written in Go.
Log | Files | Refs | README | LICENSE

commit b12d0f9ca74c6e6e1f88d014bf946ff33506ee80
parent 423b840cb8ddff202f14f83669de5d6de277cc7a
Author: Jaron Swab <jrswab@gmail.com>
Date:   Thu,  6 Jun 2019 21:25:19 -0400

strings.Contains to return on the eWttr channel.

strings.Contains was missing the last S, converted bodyData to string.

Also created a custom error message for the error channel.

Diffstat:
Mblocks/wttr.go | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/blocks/wttr.go b/blocks/wttr.go @@ -1,6 +1,7 @@ package blocks import ( + "errors" "fmt" "io/ioutil" "math" @@ -9,6 +10,8 @@ import ( "time" ) +// Wttr gets the weather of the computer's general location. +// Specify city or area code: "wttr.in/~15222" or "wttr.in/~Pittsuburgh" func Wttr(cWttr chan string, eWttr chan error) { var passed, hour float64 var data string @@ -28,8 +31,8 @@ func Wttr(cWttr chan string, eWttr chan error) { } bodyData, _ := ioutil.ReadAll(resp.Body) - if strings.Contain(bodyData, "error") { // wttr.in displays a webpage on server error - data <- "wttr.in overloaded" // display this on wttr.in server error + if strings.Contains(string(bodyData), "error") { // wttr.in displays a webpage on server error + eWttr <- errors.New("wttr.in overloaded") // display this on wttr.in server error } // convert responce to string for go channel data = string(bodyData)