file

package
v0.0.0-...-3847500 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotReferencedObject it's raised when a non pointer is received trying to parse into a struct
	ErrNotReferencedObject = errors.New("object not a pointer or reference")

	// ErrNotReferencedObject it's raised when a non pointer is received trying to parse into a struct
	ErrInvalidObject = errors.New("object specified is not valid")

	// ErrNonStructObject it's raised when the underlaying object is not an struct
	ErrNonStructObject = errors.New("underlaying object is not a struct")
)

Functions

func NewBlockScanner

func NewBlockScanner(name string) (*scanner, error)

NewBlockScanner that reads a file searching for blocks separated by empty lines Uses bufio scanner under the hood so the way of iterating thru the matches is exactly the same than using a bufio.Scanner

<START OF FILE>

First line of block 1
Second line of block 1

First line of block 2
Second line of block 2

<END OF FILE>

Will return two blocks with 2 lines each

func NewLineScanner

func NewLineScanner(name string) (*scanner, error)

func ScanBlocks

func ScanBlocks(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanBlocks represents the bufio.SplitFunc to split by blocks Example of buffer with blocks:

block 1 line 1 block 1 line 2 block 1 line 3

block 2 line 1 block 2 line 2

block 3 line 1 block 3 line 2

Types

This section is empty.

Jump to

Keyboard shortcuts

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