stringutil

package
v0.1.146 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(value string, opts NormalizeOptions) string

Normalize processes a string based on the given options.

func ParseDynamicType

func ParseDynamicType(input string) any

ParseDynamicType attempts to convert a string into the most appropriate type. The original string is returned if no conversion is possible.

func ParseQueryString

func ParseQueryString(query string) (map[string][]string, error)

ParseQueryString parses a URL query string into a key-value map.

func StringOrEmpty

func StringOrEmpty(ptr *string) string

StringOrEmpty safely dereferences a string pointer, returning an empty string if nil.

Types

type NormalizeOption

type NormalizeOption func(*NormalizeOptions)

func WithRemoveDiacritics

func WithRemoveDiacritics() NormalizeOption

WithRemoveDiacritics removes diacritics.

func WithRemoveDigits

func WithRemoveDigits() NormalizeOption

WithRemoveDigits removes numeric digits.

func WithRemoveNonASCII

func WithRemoveNonASCII() NormalizeOption

WithRemoveNonASCII removes non-ASCII characters.

func WithRemovePunctuation

func WithRemovePunctuation() NormalizeOption

WithRemovePunctuation removes punctuation.

func WithRemoveSymbols

func WithRemoveSymbols() NormalizeOption

WithRemoveSymbols removes special symbols.

func WithToLower

func WithToLower() NormalizeOption

WithToLower converts text to lowercase.

func WithTrimSpace

func WithTrimSpace() NormalizeOption

WithTrimSpace trims leading and trailing spaces.

type NormalizeOptions

type NormalizeOptions struct {
	ToLower        bool
	RemoveDiacs    bool
	TrimSpace      bool
	RemovePunct    bool
	RemoveSpec     bool
	RemoveDigits   bool
	RemoveNonASCII bool
}

func ApplyNormalizeOptions

func ApplyNormalizeOptions(opts *NormalizeOptions, modifiers ...NormalizeOption) NormalizeOptions

ApplyNormalizeOptions applies functional options to NormalizeOptions.

Jump to

Keyboard shortcuts

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