exstrings

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MPL-2.0 Imports: 5 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollapseSpaces added in v0.9.0

func CollapseSpaces(s string) string

CollapseSpaces replaces all runs of multiple spaces (\x20) in a string with a single space.

func ConstantTimeEqual

func ConstantTimeEqual(a, b string) bool

ConstantTimeEqual compares two strings using subtle.ConstantTimeCompare without copying the strings.

Note that ConstantTimeCompare is not constant time if the strings are of different length.

func ContainsFold added in v0.9.9

func ContainsFold(s, substr string) bool

func HasPrefixFold added in v0.9.9

func HasPrefixFold(s, prefix string) bool

func HasSuffixFold added in v0.9.9

func HasSuffixFold(s, suffix string) bool

func IndexFold added in v0.9.9

func IndexFold(s, substr string) int

func LongestCommonPrefix added in v0.9.3

func LongestCommonPrefix(in []string) string

func LongestSequenceOf added in v0.8.7

func LongestSequenceOf(a string, b rune) int

LongestSequenceOf returns the length of the longest contiguous sequence of a single rune in a string.

func LongestSequenceOfFunc added in v0.8.8

func LongestSequenceOfFunc(a string, fn func(b rune) int) int

LongestSequenceOfFunc returns the length of the longest contiguous sequence of runes in a string.

If the provided function returns zero or higher, the return value is added to the current count. If the return value is negative, the count is reset to zero.

func PrefixByteRunLength added in v0.9.0

func PrefixByteRunLength(s string, b byte) int

PrefixByteRunLength returns the number of the given byte at the start of a string.

func SHA256

func SHA256(str string) [32]byte

SHA256 returns the SHA-256 hash of the input string without copying the string.

func UnsafeBytes

func UnsafeBytes(str string) []byte

UnsafeBytes returns a byte slice that points to the same memory as the input string.

The returned byte slice must not be modified.

See go.mau.fi/util/exbytes.UnsafeString for the reverse operation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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