Documentation
¶
Overview ¶
Package stringutils defines utilities for working with strings; before using this package, consider using the package "strings".
Index ¶
- func AnyToString(value any) *string
- func AsBool(value string, defaultValue bool) bool
- func AsComplex(value string, bitSize int, defaultValue complex128) complex128
- func AsFloat(value string, bitSize int, defaultValue float64) float64
- func AsInt(value string, defaultValue int) int
- func AsInt64(value string, base, bitSize int, defaultValue int64) int64
- func AsUint(value string, base, bitSize int, defaultValue uint64) uint64
- func DefaultToString[T any](value T) result.Result[string]
- func ToQuoted[T any](values ...T) []string
- func ToStrings[T any](values ...T) result.Result[[]string]
- func ToStringsWith[T any](values []T, toString result.FlatMapper[T, string]) result.Result[[]string]
- func ToTitle(value string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyToString ¶
AnyToString returns nil if the given value is nil or not a string. Otherwise, casts the value to string and returns a pointer to that string.
func AsBool ¶
AsBool returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseBool. If the value cannot be parsed, then the default answer is returned.
func AsComplex ¶
func AsComplex(value string, bitSize int, defaultValue complex128) complex128
AsComplex returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseComplex. If the value cannot be parsed, then the default answer is returned.
func AsFloat ¶
AsFloat returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseFloat. If the value cannot be parsed, then the default answer is returned.
func AsInt ¶
AsInt returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#Atoi. If the value cannot be parsed, then the default answer is returned.
func AsInt64 ¶
AsInt64 returns the given string in the given base and bitSize as an int64. If the conversion fails, the given defaultValue is returned.
func AsUint ¶
AsUint returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseUint. If the value cannot be parsed, then the default answer is returned.
func DefaultToString ¶
DefaultToString returns the %v formatting of the given value.
func ToQuoted ¶
ToQuoted returns a slice of strings that is the result of adding double quotes to the %v formatting of each element of the slice.
func ToStringsWith ¶
func ToStringsWith[T any](values []T, toString result.FlatMapper[T, string]) result.Result[[]string]
ToStringsWith ...
Types ¶
This section is empty.