Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertCheckedClose ¶ added in v2.10.1
AssertCheckedClose returns a function that can be used with a defer to check that a Closer's Close method does not return an error. It is identical to CheckedClose, but uses assert instead of require.
This is primarily useful for situations that allow assert but not require, such as require.EventuallyWithT.
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.