Documentation
¶
Overview ¶
Package deferhelper contains defer-related helpers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeforeAfter ¶
func BeforeAfter(before, after func()) func()
BeforeAfter, if called in the following manner from a defer statement at the very beginning of a function,
func Example() { defer deferhelper.BeforeAfter(before(), after())() // do something }
will call 'before' function before executing the function code and 'after' function after executing the function code.
Example ¶
defer BeforeAfter(func() { fmt.Println("before") }, func() { fmt.Println("after") })() fmt.Println("in the middle")
Output: before in the middle after
func WriteBeforeAfter ¶
WriteBeforeAfter is like BeforeAfter but writes 'before' and 'after' slices to 'w' before and after executing the function code.
func WriteStringBeforeAfter ¶
WriteStringBeforeAfter is like BeforeAfter but writes 'before' and 'after' strings to 'w' before and after executing the function code.
Example ¶
defer WriteStringBeforeAfter(os.Stdout, "before\n", "after\n")() fmt.Println("in the middle")
Output: before in the middle after
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.