Documentation
¶
Index ¶
- Constants
- Variables
- func CompressSpace(text string) (output string)
- func Fields(text string) (output []string)
- func Glob(subj, pattern string) bool
- func GlobAny(subj string, patterns ...string) bool
- func Slugify(v string) string
- func SplitLines(contents string) []string
- func SplitQuoted(text, sep string) (output []string)
- func Table(wr io.Writer, columns []string, rows [][]string) error
- func TableForSlice[A any](wr io.Writer, collection []A) error
- func TrimQuotes(v string) string
- type Runeset
- type SplitLinesOptions
Constants ¶
const (
// GlobStar is the "match anything" constant.
GlobStar = "*"
)
Variables ¶
var ( // LowerLetters is a runset of lowercase letters. LowerLetters Runeset = []rune(`abcdefghijklmnopqrstuvwxyz`) // UpperLetters is a runset of uppercase letters. UpperLetters Runeset = []rune(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`) // Letters is a runset of both lower and uppercase letters. Letters = append(LowerLetters, UpperLetters...) // Numbers is a runset of numeric characters. Numbers Runeset = []rune(`0123456789`) // LettersAndNumbers is a runset of letters and numeric characters. LettersAndNumbers = append(Letters, Numbers...) // Symbols is a runset of symbol characters. Symbols Runeset = []rune(`!@#$%^&*()_+-=[]{}\|:;`) // LettersNumbersAndSymbols is a runset of letters, numbers and symbols. LettersNumbersAndSymbols = append(LettersAndNumbers, Symbols...) )
Functions ¶
func CompressSpace ¶
CompressSpace compresses whitespace characters into single spaces. It trims leading and trailing whitespace as well.
func Fields ¶
Fields splits a corpus on space but treats quoted strings, specifically any text within `"` as individual fields.
func SplitLines ¶
SplitLines splits the contents by the ascii control character `\n` with the default options applied.
To set options yourself, use `SplitLinesOptions{}.SplitLines(contents)`.
func SplitQuoted ¶
SplitQuoted splits a corpus on a given string but treats quoted strings, specifically any text within `"` as whole values.
func TableForSlice ¶
TableForSlice prints a table for a given slice. It will infer column names from the struct fields. If it is a mixed array (i.e. []interface{}) it will probably panic.
func TrimQuotes ¶
TrimQuotes trims the leading and trailing characters that match the `fieldIsQuote` function.
Types ¶
type Runeset ¶
type Runeset []rune
Runeset is a set of runes
func (Runeset) RandomProvider ¶
RandomProvider returns a random selection of runes from the set.
type SplitLinesOptions ¶
SplitLinesOptions are options for the SplitLines function.
var DefaultSplitLinesOptions SplitLinesOptions
DefaultSplitLinesOptions are the default split lines options.
func (SplitLinesOptions) SplitLines ¶
func (opts SplitLinesOptions) SplitLines(contents string) []string
SplitLines splits a corpus into individual lines by the ascii control character `\n`. You can control some behaviors of the splitting process with variadic options.