aboutsummaryrefslogtreecommitdiff
path: root/common/iowrap/write_flusher_nop.go
blob: fba87e8dfc7c9194c2601f197204624ee0bf40f9 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package iowrap

import "io"

type nopFlusher struct {
	io.Writer
}

// NopFlush adapts writer into a [WriteFlusher] with a no-op Flush.
//
//nolint:ireturn
func NopFlush(writer io.Writer) WriteFlusher {
	if writer == nil {
		return nil
	}

	return nopFlusher{Writer: writer}
}

// Flush lets us satisfy [WriteFlusher] but does nothing.
func (nopFlusher) Flush() error {
	return nil
}