All Projects → brentp → Xopen

brentp / Xopen

Licence: mit
open files for buffered reading and writing in #golang

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Xopen

Bitio
Optimized bit-level Reader and Writer for Go.
Stars: ✭ 145 (+163.64%)
Mutual labels:  reader, writer
Ini
Ini file reader/writer for C# / .NET written in pure .NET in a single source file
Stars: ✭ 43 (-21.82%)
Mutual labels:  reader, writer
Qtcsv
Library for reading and writing csv-files in Qt.
Stars: ✭ 156 (+183.64%)
Mutual labels:  reader, writer
Cistern
Ruby API client framework
Stars: ✭ 81 (+47.27%)
Mutual labels:  reader, writer
Asmresolver
A library for editing PE files with full .NET metadata support
Stars: ✭ 267 (+385.45%)
Mutual labels:  reader, writer
Parquet4s
Read and write Parquet in Scala. Use Scala classes as schema. No need to start a cluster.
Stars: ✭ 125 (+127.27%)
Mutual labels:  reader, writer
mp4-rust
🎥 MP4 reader and writer library in Rust! 🦀
Stars: ✭ 149 (+170.91%)
Mutual labels:  writer, reader
Iostreams
IOStreams is an incredibly powerful streaming library that makes changes to file formats, compression, encryption, or storage mechanism transparent to the application.
Stars: ✭ 84 (+52.73%)
Mutual labels:  reader, writer
iobit
Package iobit provides primitives for reading & writing bits
Stars: ✭ 16 (-70.91%)
Mutual labels:  writer, reader
java-class-tools
Read and write java class files in Node.js or in the browser.
Stars: ✭ 27 (-50.91%)
Mutual labels:  writer, reader
Acr122u Reader Writer
A simple tool to read/write Mifare RFID tags with an ACR122U device
Stars: ✭ 169 (+207.27%)
Mutual labels:  reader, writer
Choetl
ETL Framework for .NET / c# (Parser / Writer for CSV, Flat, Xml, JSON, Key-Value, Parquet, Yaml, Avro formatted files)
Stars: ✭ 372 (+576.36%)
Mutual labels:  reader, writer
maildir
A Go package for reading & writing messages in maildir format
Stars: ✭ 13 (-76.36%)
Mutual labels:  writer, reader
Spout
Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
Stars: ✭ 3,861 (+6920%)
Mutual labels:  reader, writer
Xml
XML without worries
Stars: ✭ 35 (-36.36%)
Mutual labels:  reader, writer
Koodo Reader
A modern ebook manager and reader with sync and backup capacities for Windows, macOS, Linux and Web
Stars: ✭ 2,938 (+5241.82%)
Mutual labels:  reader
Readingcloud
An ebook reader written in Rails.
Stars: ✭ 33 (-40%)
Mutual labels:  reader
Oho Reader
【停止维护】哦豁阅读器!API源自追书神器,免费使用!填坑完成!使用react
Stars: ✭ 571 (+938.18%)
Mutual labels:  reader
Sciencefair
The futuristic, fabulous and free desktop app for working with scientific literature 🔬 📖
Stars: ✭ 561 (+920%)
Mutual labels:  reader
Php Qrcode Detector Decoder
This is a PHP library to detect and decode QR-codes. This is first and only QR code reader that works without extensions.
Stars: ✭ 1,034 (+1780%)
Mutual labels:  reader

GoDoc Build Status Coverage Status

xopen

-- import "github.com/brentp/xopen"

xopen makes it easy to get buffered (possibly gzipped) readers and writers. and close all of the associated files. Ropen opens a file for reading. Wopen opens a file for writing. Both will use gzip when appropriate and will use buffered IO.

Usage

Here's how to get a buffered reader:

// gzipped
rdr, err := xopen.Ropen("some.gz")
// normal
rdr, err := xopen.Ropen("some.txt")
// stdin (possibly gzipped)
rdr, err := xopen.Ropen("-")
// https://
rdr, err := xopen.Ropen("http://example.com/some-file.txt")
// Cmd
rdr, err := xopen.Ropen("|ls -lh somefile.gz")
// User directory:
rdr, err := xopen.Ropen("~/brentp/somefile")

Get a buffered writer with xopen.Wopen. Get a temp file with xopen.Wopen("tmp:prefix")

func CheckBytes

func CheckBytes(b *bufio.Reader, buf []byte) (bool, error)

CheckBytes peeks at a buffered stream and checks if the first read bytes match.

func IsGzip

func IsGzip(b *bufio.Reader) (bool, error)

IsGzip returns true buffered Reader has the gzip magic.

func IsStdin

func IsStdin() bool

IsStdin checks if we are getting data from stdin.

func XReader

func XReader(f string) (io.Reader, error)

XReader returns a reader from a url string or a file.

type Reader

type Reader struct {
	*bufio.Reader
}

Reader is returned by Ropen

func Buf

func Buf(r io.Reader) *Reader

Return a buffered reader from an io.Reader If f == "-", then it will attempt to read from os.Stdin. If the file is gzipped, it will be read as such.

func Ropen

func Ropen(f string) (*Reader, error)

Ropen opens a buffered reader.

func (*Reader) Close

func (r *Reader) Close() error

Close the associated files.

type Writer

type Writer struct {
	*bufio.Writer
}

Writer is returned by Wopen

func Wopen

func Wopen(f string) (*Writer, error)

Wopen opens a buffered reader. If f == "-", then stdout will be used. If f endswith ".gz", then the output will be gzipped. If f startswith "tmp:" then a tempfile will be created with a prefix of the string following ":"

func (*Writer) Name

func (w *Writer) Name() string

The path to the underlying file handle.

func (*Writer) Close

func (w *Writer) Close() error

Close the associated files.

func (*Writer) Flush

func (w *Writer) Flush()

Flush the writer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].