stringutils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stringutils defines utilities for working with strings; before using this package, consider using the package "strings".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToString

func AnyToString(value any) *string

AnyToString returns nil if the given value is nil or not a string. Otherwise, casts the value to string and returns a pointer to that string.

func AsBool

func AsBool(value string, defaultValue bool) bool

AsBool returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseBool. If the value cannot be parsed, then the default answer is returned.

func AsComplex

func AsComplex(value string, bitSize int, defaultValue complex128) complex128

AsComplex returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseComplex. If the value cannot be parsed, then the default answer is returned.

func AsFloat

func AsFloat(value string, bitSize int, defaultValue float64) float64

AsFloat returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseFloat. If the value cannot be parsed, then the default answer is returned.

func AsInt

func AsInt(value string, defaultValue int) int

AsInt returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#Atoi. If the value cannot be parsed, then the default answer is returned.

func AsInt64

func AsInt64(value string, base, bitSize int, defaultValue int64) int64

AsInt64 returns the given string in the given base and bitSize as an int64. If the conversion fails, the given defaultValue is returned.

func AsUint

func AsUint(value string, base, bitSize int, defaultValue uint64) uint64

AsUint returns the boolean value represented by the string as per https://golang.org/pkg/strconv/#ParseUint. If the value cannot be parsed, then the default answer is returned.

func DefaultToString

func DefaultToString[T any](value T) result.Result[string]

DefaultToString returns the %v formatting of the given value.

func ToQuoted

func ToQuoted[T any](values ...T) []string

ToQuoted returns a slice of strings that is the result of adding double quotes to the %v formatting of each element of the slice.

func ToStrings

func ToStrings[T any](values ...T) result.Result[[]string]

ToStrings ...

func ToStringsWith

func ToStringsWith[T any](values []T, toString result.FlatMapper[T, string]) result.Result[[]string]

ToStringsWith ...

func ToTitle

func ToTitle(value string) string

ToTitle returns the given string in English title case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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