datadrivenutil

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package datadrivenutil defines facilities to improve ergonomics around parsing datadriven test input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields []string

Fields wraps a []string with facilities for parsing out values.

func (Fields) HasValue

func (fs Fields) HasValue(value string) bool

HasValue searches for a field that is exactly the provided string.

func (Fields) HexBytes

func (fs Fields) HexBytes() []byte

HexBytes parses all the fields as hex-encoded bytes, returning the concatenated decoded bytes. It panics if any of the fields fail to parse as hex-encoded bytes.

func (Fields) Index

func (fs Fields) Index(i int) Value

Index returns the field at index i, or the empty string if there are i or fewer fields.

func (Fields) KeyValue

func (fs Fields) KeyValue(key string) (Value, bool)

KeyValue looks for a field containing a key=value pair with the provided key. If not found, KeyValue returns false for the second return value.

func (Fields) MustKeyValue

func (fs Fields) MustKeyValue(key string) Value

MustKeyValue is like KeyValue but panics if the field is not found.

func (Fields) String

func (fs Fields) String() string

String implements fmt.Stringer.

type Line

type Line string

A Line is a string with no newlines.

func (Line) Fields

func (l Line) Fields(delims ...rune) Fields

Fields breaks the line into fields delimited by whitespace and any runes passed into the function.

type Lines

type Lines string

Lines wraps a string, providing facilities for parsing individual lines.

func (*Lines) Next

func (l *Lines) Next() (line Line)

Next returns the string up to the next newline. The receiver is modified to point to the string's contents immediately after the newline.

type Value

type Value string

A Value represents a single string of unknown structure. A Value is sometimes used to represent an entire element of a Fields and other times a substring of an individual field. This blurring of semantics is convenient for parsing.

func (Value) Bytes

func (v Value) Bytes() []byte

Bytes returns the value as a byte slice.

func (Value) HexBytes

func (v Value) HexBytes() []byte

HexBytes decodes the value as hex-encoded bytes. It panics if the value fails to decode as hex-encoded.

func (Value) Int

func (v Value) Int() int

Int parses the value as an int. It panics if the value fails to decode as an integer.

func (Value) Str

func (v Value) Str() string

Str returns the value as a string.

func (Value) Uint64

func (v Value) Uint64() uint64

Uint64 parses the value as an uint64. It panics if the value fails to decode as an uint64.

Jump to

Keyboard shortcuts

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