autoio

package
v0.0.0-...-7a0a068 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: AGPL-3.0, AGPL-3.0 Imports: 7 Imported by: 0

README

autoio.go

A lightweight (and work in progress) Go library to provide a simple interface to use compressed files like you use normal files.

Installation

$ go get github.com/abeconnelly/autoio

Example

package main

import "fmt"
import "github.com/abeconnelly/autoio"

func parrot_file( fn string ) {
  aio,err := autoio.OpenScanner( fn )
  if err!=nil { panic(err) }
  defer aio.Close()

  for aio.Scanner.Scan()  {
    l := aio.Scanner.Text()
    fmt.Println(l)
  }

}

func main() {

  parrot_file( "w.txt" )
  parrot_file( "x.txt.gz" )
  parrot_file( "y.txt.bz2" )
  parrot_file( "-" )

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoioHandle

type AutoioHandle struct {
	Fp      *os.File
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
	Reader  *bufio.Reader

	ReadScanValid bool
	FirstReadScan bool

	Bz2Reader io.Reader
	GzReader  *gzip.Reader
	FileType  string

	Error error

	ByteLine []byte
	ByteBuf  []byte
}

Wrap common stream file types into one for ease of scanning

func CreateWriter

func CreateWriter(fn string) (h AutoioHandle, err error)

func OpenReadScanner

func OpenReadScanner(fn string) (h AutoioHandle, err error)

func OpenReadScannerSimple

func OpenReadScannerSimple(fn string) (h AutoioHandle, err error)

func OpenScanner

func OpenScanner(fn string) (h AutoioHandle, err error)

func (*AutoioHandle) BufferLine

func (h *AutoioHandle) BufferLine() (bool, error)

func (*AutoioHandle) Close

func (h *AutoioHandle) Close() error

func (*AutoioHandle) Err

func (h *AutoioHandle) Err() error

func (*AutoioHandle) Flush

func (h *AutoioHandle) Flush()

func (*AutoioHandle) ReadScan

func (h *AutoioHandle) ReadScan() bool

func (*AutoioHandle) ReadText

func (h *AutoioHandle) ReadText() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL