mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 12:00:39 +00:00
8c7017a99d
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
1.5 KiB
1.5 KiB
obiutils Package: File and Stream Writing Utilities
The obiutils package provides a unified abstraction for writing data to files or streams, with optional gzip compression and buffered I/O.
Core Type: Wfile
- Encapsulates a write-ready output stream (
io.WriteCloser). - Supports both compressed (gzip) and uncompressed modes.
- Uses
bufio.Writerfor efficient buffered writes.
Key Functions
OpenWritingFile(name string, compressed bool, append bool) (*Wfile, error)
- Opens a file for writing.
compressed: enables gzip compression viapgzip.append: if true, writes at end of file (os.O_APPEND).
- Returns a ready-to-use
*Wfile.
CompressStream(out io.WriteCloser, compressed bool, close bool) (*Wfile, error)
- Wraps an arbitrary
io.WriteCloser(e.g., HTTP response, pipe) in buffered/compressed I/O.close: if true, the underlying writer is closed on.Close().
Methods
-
Write(p []byte)/WriteString(s string):
Buffered writes to the underlying stream (transparently compressed if enabled). -
Close():- Flushes the buffer.
- Closes gzip writer (if compressed).
- Closes underlying file/stream only if
close == true.
Design Highlights
- Transparent compression: Uses high-performance
pgzipfor parallel gzip. - Resource control: Explicit flag (
close) prevents premature closure of shared writers (e.g., in pipelines). - Efficiency: Double buffering via
bufio.Writer+ gzip stream.