util

package
v2.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanConvert

func CanConvert(data interface{}, optionType types.OptionType) (bool, error)

func ConvertString

func ConvertString(value string, data any, arg string, delimiterFunc types.ListDelimiterFunc, useAppend ...bool) error

func DamerauLevenshteinDistance added in v2.4.2

func DamerauLevenshteinDistance(s1, s2 string) int

DamerauLevenshteinDistance calculates the restricted Damerau-Levenshtein distance (Optimal String Alignment) between two strings. Supports insertion, deletion, substitution, and transposition of adjacent characters. This implementation is Unicode-aware and works correctly with multi-byte characters.

func LevenshteinDistance added in v2.3.0

func LevenshteinDistance(s1, s2 string) int

LevenshteinDistance is a deprecated alias for DamerauLevenshteinDistance. Deprecated: Use DamerauLevenshteinDistance instead.

func NewOfType

func NewOfType[T any](value T) *T

func Truncate added in v2.3.0

func Truncate(s string, length int) string

Truncate truncates a string to the specified length

func UniqueID added in v2.3.0

func UniqueID(prefix string) string

UniqueID creates a unique identifier for parsers by combining a nanosecond timestamp with an atomic counter to ensure uniqueness

func UnwrapType

func UnwrapType(t reflect.Type) reflect.Type

UnwrapType recursively unwraps pointer.go types and returns the underlying type

func UnwrapValue

func UnwrapValue(v reflect.Value) (reflect.Value, error)

UnwrapValue recursively unwraps pointer and returns the underlying value Returns the zero Value if a nil pointer is encountered

Types

type Number

type Number struct {
	Int        int64
	Float      float64
	Complex    complex128
	IsInt      bool
	IsFloat    bool
	IsComplex  bool
	IsNegative bool
}

func ParseNumeric

func ParseNumeric(s string) (n Number, ok bool)

Jump to

Keyboard shortcuts

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