parseutils

package
v0.0.0-...-faa13c8 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// replace once conventions includes these
	AttributeURLUserInfo = "url.user_info"
	AttributeURLUsername = "url.username"
	AttributeURLPassword = "url.password"
)

Variables

This section is empty.

Functions

func MapCSVHeaders

func MapCSVHeaders(headers []string, fields []string) (map[string]any, error)

MapCSVHeaders creates a map of headers[i] -> fields[i].

func ParseKeyValuePairs

func ParseKeyValuePairs(pairs []string, delimiter string) (map[string]any, error)

ParseKeyValuePairs will split each string in `pairs` on the `delimiter` into a key and value string that get added to a map and returned.

func ParseURI

func ParseURI(value string, semconvCompliant bool) (map[string]any, error)

parseURI takes an absolute or relative uri and returns the parsed values.

func ReadCSVRow

func ReadCSVRow(row string, delimiter rune, lazyQuotes bool) ([]string, error)

ReadCSVRow reads a CSV row from the csv reader, returning the fields parsed from the line. We make the assumption that the payload we are reading is a single row, so we allow newline characters in fields. However, the csv package does not support newlines in a CSV field (it assumes rows are newline separated), so in order to support parsing newlines in a field, we need to stitch together the results of multiple Read calls.

func SplitString

func SplitString(input, delimiter string) ([]string, error)

SplitString will split the input on the delimiter and return the resulting slice while respecting quotes. Outer quotes are stripped. Use in place of `strings.Split` when quotes need to be respected. Requires `delimiter` not be an empty string

Types

This section is empty.

Jump to

Keyboard shortcuts

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