stringutil

package
v0.0.0-...-bbf015a Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtrOr

func BoolPtrOr(ptr *bool, fallback bool) bool

BoolPtrOr dereferences a *bool, returning fallback if the pointer is nil.

func BuildProviderOrder

func BuildProviderOrder(primary string, fallbacks []string, defaultOrder []string) []string

BuildProviderOrder constructs a deduplicated provider order list. primary is placed first (unless empty or "auto"), followed by fallbacks. If the resulting list is empty, a clone of defaultOrder is returned.

func DedupeStrings

func DedupeStrings(values []string) []string

DedupeStrings returns a deduplicated copy of values, preserving order. Empty strings and strings that are empty after trimming are skipped.

func EnvOr

func EnvOr(existing, value string) string

EnvOr returns value (trimmed) if non-empty, otherwise returns existing.

func FirstNonEmpty

func FirstNonEmpty(values ...string) string

FirstNonEmpty returns the first non-empty string after trimming.

func NormalizeBaseURL

func NormalizeBaseURL(value string) string

NormalizeBaseURL trims whitespace and trailing slashes from a URL.

func NormalizeElevatedLevel

func NormalizeElevatedLevel(raw string) (string, bool)

NormalizeElevatedLevel normalizes a raw elevated-level string to one of the canonical values: "off", "full", "ask", or "on". Returns the normalized value and true if recognized, or ("", false) for unrecognized input.

func NormalizeEnum

func NormalizeEnum(raw string, aliases map[string]string) (string, bool)

NormalizeEnum normalizes a raw string to a canonical enum value. It lowercases and trims the input, then looks it up in the aliases map. Returns the canonical value and true if found, or ("", false) if not.

func NormalizeMimeType

func NormalizeMimeType(mimeType string) string

NormalizeMimeType lowercases, trims whitespace, and strips parameters from a MIME type.

func SplitCSV

func SplitCSV(value string) []string

SplitCSV splits a comma-separated string into trimmed, non-empty parts.

func StripMarkup

func StripMarkup(text string) string

StripMarkup removes common HTML/markdown formatting that models might wrap tokens in.

Types

This section is empty.

Jump to

Keyboard shortcuts

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