Documentation ¶
Overview ¶
Package rstrings contains string and file-based operations, such as reading a file into a string
Index ¶
- func CsvToMap(fname string) (result map[string][]string, err error)
- func DefaultIfEmpty(s, deflt string) string
- func EnsurePrefix(input string, prefix string) string
- func EnsureSuffix(input string, suffix string) string
- func EnsureWrapped(input string, wrapper string) string
- func FileToString(fname string) (result string, err error)
- func IsEmpty(s string) bool
- func LeftPad(input string, length int) string
- func LeftPadWith(input string, char rune, length int) string
- func MapToString(input map[string]interface{}, isPretty ...bool) string
- func RightPad(input string, length int) string
- func RightPadWith(input string, char rune, length int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CsvToMap ¶ added in v0.3.1
CsvToMap takes the given filename, reads the file in CSV format, and returns a 2d map first dimension is the column name, second dimension is the row values for that column. input CSV file is expected to have a header row.
func DefaultIfEmpty ¶ added in v0.3.1
DefaultIfEmpty returns the given string. If the given string is empty (see rstrings.IsEmpty), the given default is returned
func EnsurePrefix ¶ added in v0.4.1
EnsurePrefix prefixes the given string with the given prefix if it doesn't have it already examples: EnsurePrefix("foo", "f") = "foo" EnsurePrefix("foo", "new-") = "new-foo"
func EnsureSuffix ¶ added in v0.4.1
EnsureSuffix suffixes the given string with the given suffix if it doesn't have it already examples: EnsureSuffix("foo", "o") = "foo" EnsureSuffix("foo", "-new") = "foo-new"
func EnsureWrapped ¶ added in v0.4.1
EnsureWrapped wraps the given string with the given prefix/suffix if it doesn't have it already examples: EnsureWrapped("foo", "'") = "'foo'" EnsureSuffix("fluff", "f") = "fluff"
func FileToString ¶ added in v0.2.0
FileToString reads from the given filename and returns the contents as a string
func IsEmpty ¶
IsEmpty returns whether the given string has a length of 0 or is only whitespace examples: IsEmpty("") = true IsEmpty(" ") = True IsEmpty("b") = false IsEmpty(" b") = false IsEmpty("b ") = false IsEmpty(" b ") = false
func LeftPad ¶ added in v0.4.0
LeftPad prepend-pads the given string to the desired length with space characters. See LeftPadWith for implementation details
func LeftPadWith ¶ added in v0.4.0
LeftPadWith prepend-pads the given string to the given length with the given rune. If the input string is already longer than the desired length, it is returned and NOT truncated
func MapToString ¶ added in v0.3.1
MapToString converts the given map to a string. The variadic bool is a flag indicating whether the result should be prettified with newlines and whitespace default is false, for compatibility
Types ¶
This section is empty.