kv

package
v0.0.0-...-17244d7 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package kv reads key value files.

Index

Constants

Variables

View Source
var ErrBadLine = errors.New("bad line")

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Key   string
	Value string
}

type Reader

type Reader struct {
	// Delim is key value delimiter
	Delim byte
	// Comment, if not 0, is the comment character. Lines begin with the
	// Comment character are ignored.
	Comment byte
	// TrimSpace determines the behavior of trim space
	TrimSpace TrimSpaceFlag
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader that reads from r. The Delim field default to '=', the TrimSpace field default to TrimAllSpace.

func (*Reader) Read

func (r *Reader) Read() (pair *Pair, err error)

Read reads one pair from r.

func (*Reader) ReadAll

func (r *Reader) ReadAll() (pairs []*Pair, err error)

ReadAll reads all the remaining pairs from r. A successful call returns err == nil, not err == io.EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.

type TrimSpaceFlag

type TrimSpaceFlag uint
const (
	TrimLeadingSpace TrimSpaceFlag = 1 << iota
	TrimTailingSpace
	TrimDelimLeftSpace
	TrimDelimRightSpace
)

Jump to

Keyboard shortcuts

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