diff --git a/modules/finnhub/client.go b/modules/finnhub/client.go index 44c518b7..45dd7c7c 100644 --- a/modules/finnhub/client.go +++ b/modules/finnhub/client.go @@ -1,10 +1,10 @@ package finnhub import ( + "encoding/json" "fmt" "net/http" "net/url" - "encoding/json" ) // Client .. @@ -35,7 +35,10 @@ func (client *Client) Getquote() ([]Quote, error) { var quote Quote quote.Stock = s - json.NewDecoder(resp.Body).Decode("e) + err = json.NewDecoder(resp.Body).Decode("e) + if err != nil { + return quotes, err + } quotes = append(quotes, quote) } diff --git a/modules/finnhub/client_test.go b/modules/finnhub/client_test.go index 91647ee7..c73be5ad 100644 --- a/modules/finnhub/client_test.go +++ b/modules/finnhub/client_test.go @@ -1,11 +1,12 @@ package finnhub import ( - "fmt" + "fmt" "testing" ) -func TestFinnhubClient(t *testing.T){ - testClient := &Client { + +func TestFinnhubClient(t *testing.T) { + testClient := &Client{ symbols: []string{ "AAPL", "MSFT", @@ -21,4 +22,4 @@ func TestFinnhubClient(t *testing.T){ fmt.Println(r[0].Stock, r[0].C) fmt.Println(r[1].Stock, r[1].C) -} \ No newline at end of file +} diff --git a/modules/finnhub/quote.go b/modules/finnhub/quote.go index b8e9af86..36704b28 100644 --- a/modules/finnhub/quote.go +++ b/modules/finnhub/quote.go @@ -9,4 +9,4 @@ type Quote struct { T int `json:"t"` Stock string -} \ No newline at end of file +} diff --git a/modules/finnhub/widget.go b/modules/finnhub/widget.go index f39aed37..378d11d3 100644 --- a/modules/finnhub/widget.go +++ b/modules/finnhub/widget.go @@ -42,7 +42,7 @@ func (widget *Widget) Refresh() { func (widget *Widget) content() (string, string, bool) { quotes, err := widget.Client.Getquote() - title := fmt.Sprintf("%s", widget.CommonSettings().Title) + title := widget.CommonSettings().Title var str string wrap := false if err != nil {