Documentation ¶
Overview ¶
Package textutils provides common helper functions for text manipulation or output used by applications in this module.
Index ¶
- Constants
- func BytesToDelimitedHexStr(bx []byte, delimiter string) string
- func DedupeList(list []string) []string
- func FailedMatches(expectedList []string, searchList []string, ignoreCase bool) []string
- func InList(needle string, haystack []string, ignoreCase bool) bool
- func InsertDelimiter(s string, delimiter string, pos int) string
- func IntSliceToStringSlice(ix []int) []string
- func LowerCaseStringSlice(xs []string) []string
- func Matches(expectedList []string, searchList []string, ignoreCase bool) ([]string, []string)
- func NormalizeNewlines(input []byte) []byte
- func PrintHeader(headerText string)
- func StripBlankAndNormalize(input []byte) []byte
- func StripBlankLines(input []byte) []byte
Constants ¶
const ( WindowsEOL = "\r\n" MacEOL = "\r" UnixEOL = "\n" )
Confirmed newline/EOL values.
Variables ¶
This section is empty.
Functions ¶
func BytesToDelimitedHexStr ¶
BytesToDelimitedHexStr converts a byte slice to a delimited hex string.
func DedupeList ¶
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
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 ¶
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 ¶
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 ¶
IntSliceToStringSlice converts a slice of integers to a slice of string.
func LowerCaseStringSlice ¶
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
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 NormalizeNewlines ¶ added in v0.19.0
NormalizeNewlines replaces all Windows and Mac newlines with Unix newlines.
Use this with caution if applying directly to binary files (e.g., it can break parsing of DER binary certificate files).)
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.
func StripBlankAndNormalize ¶ added in v0.19.0
StripBlankAndNormalize removes all blank lines and normalizes all remaining newlines (converting Windows and Mac-specific EOLs to Unix EOLs) from given input.
func StripBlankLines ¶ added in v0.19.0
StripBlankLines removes all blank lines from given input. Newlines are not normalized.
Types ¶
This section is empty.