textutils

package
v0.15.9-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package textutils provides common helper functions for text manipulation or output used by applications in this module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToDelimitedHexStr

func BytesToDelimitedHexStr(bx []byte, delimiter string) string

BytesToDelimitedHexStr converts a byte slice to a delimited hex string.

func DedupeList

func DedupeList(list []string) []string

DedupeList returns a copy of a provided string slice with all duplicate entries removed. FIXME: Is there already a standard library version of this functionality?

func FailedMatches added in v0.8.0

func FailedMatches(expectedList []string, searchList []string, ignoreCase bool) []string

FailedMatches evaluates a list of values using list of expected values. A list of failed matches or an empty (non-nil) list is returned. If specified, a case-insensitive comparison is used.

func InList

func InList(needle string, haystack []string, ignoreCase bool) bool

InList is a helper function to emulate Python's `if "x" in list:` functionality. The caller can optionally ignore case of compared items.

func InsertDelimiter

func InsertDelimiter(s string, delimiter string, pos int) string

InsertDelimiter inserts a delimiter into the provided string every pos characters. If the length of the provided string is less than pos + 1 characters the original string is returned unmodified as we are unable to insert delimiter between blocks of characters of specified (pos) size.

func IntSliceToStringSlice

func IntSliceToStringSlice(ix []int) []string

IntSliceToStringSlice converts a slice of integers to a slice of string.

func LowerCaseStringSlice

func LowerCaseStringSlice(xs []string) []string

LowerCaseStringSlice is a helper function to convert all provided string slice elements to lowercase.

FIXME: There is likely a better way to do this already; replace with that better way.

func Matches added in v0.8.0

func Matches(expectedList []string, searchList []string, ignoreCase bool) ([]string, []string)

Matches returns a list of successful matches and a list of failed matches for the provided lists of expected and total values. If specified, a case-insensitive comparison is used.

func PrintHeader

func PrintHeader(headerText string)

PrintHeader prints a section header with liberal leading and trailing newlines to help separate otherwise potentially dense blocks of text.

Types

This section is empty.

Jump to

Keyboard shortcuts

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