-
Notifications
You must be signed in to change notification settings - Fork 6
Errors
Zelenko edited this page May 1, 2019
·
1 revision
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:
package shop
if err == fruits.NoMorePumpkins {
...
}