errdefer

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(err *error, closer io.Closer)

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)
	// ...
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL