Go: Panic Recover and Return Values

nwillc
2 min readMay 14, 2021

In working with external code I hit the following. The code provided a function for looking up a product’s price, returning the price if available and a possible error:

func Price(product string) (float64, error)

It was a simple function, and the error case was sensible, unknown product, out of stock, etc. However, I discovered that when the item was discontinued the function…

--

--

nwillc

Graybeard code monkey, started on an Apple IIe, got a CS degree in the 80’s, and coded my way through C, C++, Objective-C, Java, Kotlin — and now Go.