Discover Packages
go.abhg.dev/doc2go
internal
errdefer
package
Version:
v0.5.1
Opens a new window with list of versions in this module.
Published: Nov 11, 2023
License: Apache-2.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package errdefer provides functions for running operations
that must be deferred until the end of a function,
but which may return errors that should be returned from the function.
Close calls Close on the given Closer,
and joins any error returned with the given error.
Use it inside a defer statement with a named return like this:
func foo() (err error) {
f, err := os.Open("foo.txt")
if err != nil {
return err
}
defer errdefer.Close(&err, f)
// ...
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.