textutil

package
v0.15.10 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SimulatedNullString      = sqltypes.NULL.String()
	SimulatedNullStringSlice = []string{sqltypes.NULL.String()}
	SimulatedNullInt         = -1
)

Functions

func EscapeJoin

func EscapeJoin(elems []string, sep string) string

EscapeJoin acts like strings.Join, except it first escapes elements via net/url

func ExecuteTemplate

func ExecuteTemplate(tmpl *template.Template, data any) (string, error)

ExecuteTemplate executes the given text template with the given data, and returns the resulting string.

func RandomHash

func RandomHash() string

RandomHash returns a 64 hex character random string

func SingleWordCamel

func SingleWordCamel(w string) string

SingleWordCamel takes a single word and returns is in Camel case; basically just capitalizing the first letter and making sure the rest are lower case.

func SplitDelimitedList

func SplitDelimitedList(s string) (list []string)

SplitDelimitedList splits a given string by comma, semi-colon or space, and returns non-empty strings

func SplitUnescape

func SplitUnescape(s string, sep string) ([]string, error)

SplitUnescape acts like strings.Split, except it then unescapes tokens via net/url

func Title

func Title(s string) string

Title returns a copy of the string s with all Unicode letters that begin words mapped to their Unicode title case.

This is a simplified version of `strings.ToTitle` which is deprecated as it doesn't handle all Unicode characters correctly. But we don't care about those, so we can use this. This avoids having all of `x/text` as a dependency.

func TruncateText

func TruncateText(text string, limit int, location TruncationLocation, indicator string) (string, error)

TruncateText truncates the provided text, if needed, to the specified maximum length using the provided truncation indicator in place of the truncated text in the specified location of the original string.

func UUIDv5

func UUIDv5(inputs ...string) string

UUIDv5 creates a UUID v5 string based on the given inputs. We use a SHA256 algorithm. Return format is textual

func UUIDv5Base36

func UUIDv5Base36(inputs ...string) string

UUIDv5Base36 creates a UUID v5 string based on the given inputs. Return value is a 25 character, base36 string

func UUIDv5Val

func UUIDv5Val(inputs ...string) big.Int

UUIDv5Val creates a UUID v5 string based on the given inputs. Return value is a big.Int

func ValueIsSimulatedNull

func ValueIsSimulatedNull(val any) bool

ValueIsSimulatedNull returns true if the value represents a NULL or unknown/unspecified value. This is used to distinguish between a zero value / default and a user provided value that is equivalent (e.g. an empty string or slice).

Types

type TruncationLocation

type TruncationLocation int
const (
	TruncationLocationMiddle TruncationLocation = iota
	TruncationLocationEnd
)

Jump to

Keyboard shortcuts

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