Grokking Advanced Go
0% completed
errors Is, As, and AsType
The program below has a bug. The function reserve fails because an item is out of stock, and the caller checks for exactly that failure, yet the check is false.
Output:
unexpected failure: reserve SKU-1: out of stock
The check worked until someone added context to the error in reserve, and the program still compiled after that change. How should code test for an error that may be wrapped, and how can it read the fields of an error type inside a chain?
The Limit of ==
How Interface Values Work showed that
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%