diff options
author | 2025-03-09 17:47:56 +0100 | |
---|---|---|
committer | 2025-03-10 01:59:49 +0100 | |
commit | 3ac1ee16f377d31a0fb80c8dae28b6239ac4229e (patch) | |
tree | f61faa581feaaeaba2542b9f2b8234a590684413 /vendor/codeberg.org/gruf/go-iotools/close.go | |
parent | [chore] update URLs to forked source (diff) | |
download | gotosocial-3ac1ee16f377d31a0fb80c8dae28b6239ac4229e.tar.xz |
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-iotools/close.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-iotools/close.go | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/vendor/codeberg.org/gruf/go-iotools/close.go b/vendor/codeberg.org/gruf/go-iotools/close.go deleted file mode 100644 index f3d4814ba..000000000 --- a/vendor/codeberg.org/gruf/go-iotools/close.go +++ /dev/null @@ -1,52 +0,0 @@ -package iotools - -import "io" - -// NopCloser is an empty -// implementation of io.Closer, -// that simply does nothing! -type NopCloser struct{} - -func (NopCloser) Close() error { return nil } - -// CloserFunc is a function signature which allows -// a function to implement the io.Closer type. -type CloserFunc func() error - -func (c CloserFunc) Close() error { - return c() -} - -// CloserCallback wraps io.Closer to add a callback deferred to call just after Close(). -func CloserCallback(c io.Closer, cb func()) io.Closer { - return CloserFunc(func() error { - defer cb() - return c.Close() - }) -} - -// CloserAfterCallback wraps io.Closer to add a callback called just before Close(). -func CloserAfterCallback(c io.Closer, cb func()) io.Closer { - return CloserFunc(func() (err error) { - defer func() { err = c.Close() }() - cb() - return - }) -} - -// CloseOnce wraps an io.Closer to ensure it only performs the close logic once. -func CloseOnce(c io.Closer) io.Closer { - return CloserFunc(func() error { - if c == nil { - // already run. - return nil - } - - // Acquire. - cptr := c - c = nil - - // Call the closer. - return cptr.Close() - }) -} |