filex

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstLine

func FirstLine(filename string) (string, error)

FirstLine returns the first line of the file.

func LastLine

func LastLine(filename string) (string, error)

LastLine returns the last line of the file.

Types

type OffsetRange

type OffsetRange struct {
	File  string
	Start int64
	Stop  int64
}

OffsetRange represents a content block of a file.

func SplitLineChunks

func SplitLineChunks(filename string, chunks int) ([]OffsetRange, error)

SplitLineChunks splits file into chunks. The whole line are guaranteed to be split in the same chunk.

type RangeReader

type RangeReader struct {
	// contains filtered or unexported fields
}

A RangeReader is used to read a range of content from a file.

func NewRangeReader

func NewRangeReader(file *os.File, start, stop int64) *RangeReader

NewRangeReader returns a RangeReader, which will read the range of content from file.

func (*RangeReader) Read

func (rr *RangeReader) Read(p []byte) (n int, err error)

Read reads the range of content into p.

type Scanner

type Scanner interface {
	// Scan checks if has remaining to read.
	Scan() bool
	// Text returns next line.
	Text() string
}

A Scanner is used to read lines.

func NewProgressScanner

func NewProgressScanner(scanner Scanner, bar *pb.ProgressBar) Scanner

NewProgressScanner returns a Scanner with progress indicator.

Jump to

Keyboard shortcuts

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