finnhub-go
finnhub-go copied to clipboard
Quote not returning error value when there is an error
I am writing wrapper function to simply get Quotes and pass the data back through a channel:
quote, _, err := finnhubClient.Quote(context.Background()).Symbol(ticker).Execute()
if err != nil {
stockQuote := StockQuoteInfo{CurrentPrice: 0.0, Change: 0.0, PercentChange: 0.0}
ch <- StockQuoteAndError{StockQuote: stockQuote, Error: err}
return
}
var quoteInfo StockQuoteInfo = StockQuoteInfo{CurrentPrice: *quote.C, Change: *quote.D, PercentChange: *quote.Dp}
ch <- StockQuoteAndError{StockQuote: quoteInfo, Error: nil}
When I pass an invalid ticker symbol such as "ABCDE", the err != nil block does not get executed and the "err" variable is set to nil, however when I attempt to access values inside the "quote" response they are nil pointers to invalid memory addresses. This causes my application to panic and crash.
Why is no error being returned when the quote data returned is not valid?