-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
Good day.
This is proposal to add the Temporary function into errors package. I tend to rewrite it over and over again in every project.
Possible implementation:
// Temporary returns true if it makes sense to retry the call that returned the error.
func Temporary(err error) bool {
if err, ok := err.(interface{ Temporary() bool }); ok {
return err.Temporary()
}
return false
}
Mainly, this function will be used in conjunction with the net package.
Nevertheless, I think Temporary function belongs to the erros package, in this case user code and other packages may follow the same convention.
The main reason for adding a new function into the go standard library is to promote the "Temporary" concept.
If there's no common mechanism to determine if operation can be retried then error handling becomes more intricate.
Also, I think the function is in line with the "errors are values."