Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeferGroup ¶
type DeferGroup struct {
// contains filtered or unexported fields
}
Just like "defer", but can be canceled. Useful in constructor functions when there are multiple resources need to be acquired, but that can fail to be allocated itself.
Examples:
dg := DeferGroup{} defer dg.Exec() resource, err := Allocate() if err != nil { return err } dg.Defer(func() { resource.Close() }) // More allocations. dg.CancelExec() // Everything is OK, no cleanup required. return nil
func (*DeferGroup) CancelExec ¶
func (m *DeferGroup) CancelExec()
func (*DeferGroup) Defer ¶
func (m *DeferGroup) Defer(fn func())
func (*DeferGroup) Exec ¶
func (m *DeferGroup) Exec()
Click to show internal directories.
Click to hide internal directories.