filex

package
v0.0.0-...-9b66df9 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 4 Imported by: 0

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