Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckedClose ¶
CheckedClose returns a function that can be used with a defer to check that a Closer's Close method does not return an error.
By using CheckedClose, the following code: defer func() { require.NoError(t, c.Close()) }() can be replaced by: defer CheckedClose(t, c)()
func CheckedCloseOnce ¶
CheckedCloseOnce returns a function that will call Close on c and check for errors. The returned function has no effect after being called the first time. It can be used to replace code like the following:
c := NewSomeCloser()
defer func() {
if c != nil {
require.NoError(c.Close())
c = nil
}
}()
...
require.NoError(t, c.Close())
c = nil
Example:
closer := CheckedCloseOnce(t, c) defer closer() ... closer()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.