Define an error value in a library
package fruits var NoMorePumpkins = errors.New("No more pumpkins")
Do not create errors with errors.New anywhere in the code but return the predefined value whenever error occurs and then you can do the following:
errors.New
package shop if err == fruits.NoMorePumpkins { ... }
There was an error while loading. Please reload this page.