closers

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 3 Imported by: 6

Documentation

Overview

Package closers contains utilities for dealing with io.Closer implementations

Index

Constants

This section is empty.

Variables

View Source
var Noop io.Closer = &noopCloser{}

Noop is an io.Closer implementation that does nothing.

Functions

func Close

func Close(c io.Closer)

Close the given closer. If a non-nil error is returned, it is logged.

func CloseAll added in v1.4.1

func CloseAll(cs ...io.Closer)

CloseAll calls Close on all io.Closer implementations passed as arguments.

func CloseFunc added in v1.1.0

func CloseFunc(fn func() error) io.Closer

CloseFunc wraps te provider function as an io.Closer implementation. This can be used when you have a type that has some form of close method that does not directly implement io.Closer.

Types

type MultiCloser added in v1.4.1

type MultiCloser []io.Closer

The MultiCloser type is a collection of io.Closer implementations that can be collected and closed at once.

func (*MultiCloser) Add added in v1.4.1

func (c *MultiCloser) Add(cl io.Closer)

Add a closer to the MultiCloser. It will be closed when calling MultiCloser.Close.

func (*MultiCloser) Close added in v1.4.1

func (c *MultiCloser) Close() error

Close all io.Closer implementations in the MultiCloser. Returns any non-nil errors as a multi-error.

Jump to

Keyboard shortcuts

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