diff options
| author | 2026-03-28 19:57:10 +0000 | |
|---|---|---|
| committer | 2026-03-28 19:57:10 +0000 | |
| commit | 196c8924b697f145661a1bd762c1184e65000520 (patch) | |
| tree | f5e087eb59f16552cbd47402388afae4324ea838 /common | |
| parent | network/receivepack/hooks: Fix whitespace (diff) | |
| signature | No signature | |
common/iowrap: Add io wrappers
Diffstat (limited to 'common')
| -rw-r--r-- | common/doc.go | 2 | ||||
| -rw-r--r-- | common/iowrap/doc.go | 2 | ||||
| -rw-r--r-- | common/iowrap/nop_flush.go | 20 | ||||
| -rw-r--r-- | common/iowrap/write_flusher.go | 9 |
4 files changed, 33 insertions, 0 deletions
diff --git a/common/doc.go b/common/doc.go new file mode 100644 index 00000000..1f685411 --- /dev/null +++ b/common/doc.go @@ -0,0 +1,2 @@ +// Package common encapsulates various helper packages not directly related to Git. +package common diff --git a/common/iowrap/doc.go b/common/iowrap/doc.go new file mode 100644 index 00000000..8e25db16 --- /dev/null +++ b/common/iowrap/doc.go @@ -0,0 +1,2 @@ +// Package iowrap provides small public I/O wrapper interfaces and adapters. +package iowrap diff --git a/common/iowrap/nop_flush.go b/common/iowrap/nop_flush.go new file mode 100644 index 00000000..38fc5f55 --- /dev/null +++ b/common/iowrap/nop_flush.go @@ -0,0 +1,20 @@ +package iowrap + +import "io" + +type nopFlusher struct { + io.Writer +} + +// NopFlush adapts writer into a WriteFlusher with a no-op Flush. +func NopFlush(writer io.Writer) WriteFlusher { + if writer == nil { + return nil + } + + return nopFlusher{Writer: writer} +} + +func (nopFlusher) Flush() error { + return nil +} diff --git a/common/iowrap/write_flusher.go b/common/iowrap/write_flusher.go new file mode 100644 index 00000000..aaac8724 --- /dev/null +++ b/common/iowrap/write_flusher.go @@ -0,0 +1,9 @@ +package iowrap + +import "io" + +// WriteFlusher writes bytes and flushes buffered output state. +type WriteFlusher interface { + io.Writer + Flush() error +} |
