strings

package
v1.76.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSliceFromAny

func ByteSliceFromAny(a any) ([]byte, bool)

func HasAnyPrefix

func HasAnyPrefix(s string, prefixes ...string) bool

func HexEscapeNonASCII

func HexEscapeNonASCII(s string) string

HexEscapeNonASCII percent-encodes every non-ASCII byte (>= utf8.RuneSelf) in s and leaves ASCII bytes untouched. It mirrors the unexported net/http helper used to keep header values such as Location valid ASCII. Note that ASCII control bytes, including CR and LF, are not escaped.

func Levenshtein added in v1.47.0

func Levenshtein(a []rune, b []rune) int

Levenshtein is the edit distance between two rune slices: the fewest single-rune insertions, deletions and substitutions that turn one into the other.

Named for the metric rather than called an edit distance, because several distances answer to that description and they disagree. Damerau-Levenshtein counts a transposition as one edit where this counts two, and a caller comparing text a human typed usually wants the former.

Computed with two rows rather than the full matrix. The inputs this was written for are short — a sentence, a paragraph — but there are a great many of them, and the allocation is what would be felt rather than the arithmetic.

func MakeTextualRepresentation

func MakeTextualRepresentation(value any) (string, error)

func ShellJoin

func ShellJoin(args []string) string

ShellJoin constructs a shell-quoted string from a list of tokens (ported from Python).

Types

This section is empty.

Jump to

Keyboard shortcuts

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