Documentation ¶
Overview ¶
Package cleanup provides utilities to clean "stuff" on defers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cleanup ¶
type Cleanup struct {
// contains filtered or unexported fields
}
Cleanup allows defers to be aborted when cleanup needs to happen conditionally. Usage:
cu := cleanup.Make(func() { f.Close() }) defer cu.Clean() // failure before release is called will close the file. ... cu.Add(func() { f2.Close() }) // Adds another cleanup function ... cu.Release() // on success, aborts closing the file. return f
func (*Cleanup) Add ¶
func (c *Cleanup) Add(f func())
Add adds a new function to be called on Clean().
Click to show internal directories.
Click to hide internal directories.