ucast

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 4 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToString

func BoolToString(v *bool) string

BoolToString converts a bool to string

func Float32ToString

func Float32ToString(v *float32) string

Float32ToString converts a float32 to string

func Float64ToFloat32

func Float64ToFloat32(v *float64) float32

Float64ToFloat32 converts a float64 to float32

func Float64ToString

func Float64ToString(v *float64) string

Float64ToString converts a float64 to string

func Int8ToString

func Int8ToString(v *int8) string

Int8ToString converts an int64 to string

func Int16ToString

func Int16ToString(v *int16) string

Int16ToString converts an int64 to string

func Int32ToString

func Int32ToString(v *int32) string

Int32ToString converts an int64 to string

func Int64ToString

func Int64ToString(v *int64) string

Int64ToString converts an int64 to string

func IntToString

func IntToString(v *int) string

IntToString converts an int to string

func String

func String[R uconst.BasicType](str string) (R, error)

String converts the input string to a value of type R. It returns the converted value and an error if the conversion fails.

The type R must satisfy the uconst.BasicType constraint.

Example usage:

value, err := ucast.String[int]("123")
if err != nil {
    // handle error
}

func StringOrDef

func StringOrDef[R uconst.BasicType](str string, def R) (R, error)

StringOrDef attempts to convert the input string to a value of type R. If the conversion fails, it returns the default value def and an error.

The type R must satisfy the uconst.BasicType constraint.

Example usage:

value, err := ucast.StringOrDef[int]("invalid", 42)
// value == 42, err != nil

func StringToBool

func StringToBool(v *string) (bool, error)

StringToBool converts a string to bool

func StringToFloat32

func StringToFloat32(v *string) (float32, error)

StringToFloat32 converts a string to float32

func StringToFloat64

func StringToFloat64(v *string) (float64, error)

StringToFloat64 converts a string to float64

func StringToInt

func StringToInt(v *string) (int, error)

StringToInt converts a string to int

func StringToInt8

func StringToInt8(v *string) (int8, error)

StringToInt8 converts a string to int8

func StringToInt16

func StringToInt16(v *string) (int16, error)

StringToInt16 converts a string to int16

func StringToInt32

func StringToInt32(v *string) (int32, error)

StringToInt32 converts a string to int32

func StringToInt64

func StringToInt64(v *string) (int64, error)

StringToInt64 converts a string to int64

func StringToUint

func StringToUint(v *string) (uint, error)

StringToUint converts a string to uint

func StringToUint8

func StringToUint8(v *string) (uint8, error)

StringToUint8 converts a string to uint8

func StringToUint16

func StringToUint16(v *string) (uint16, error)

StringToUint16 converts a string to uint16

func StringToUint32

func StringToUint32(v *string) (uint32, error)

StringToUint32 converts a string to uint32

func StringToUint64

func StringToUint64(v *string) (uint64, error)

StringToUint64 converts a string to uint64

func Type

func Type[V uconst.BasicType](v V) string

Type converts the input value v of type V to its string representation.

The type V must satisfy the uconst.BasicType constraint.

Example usage:

str := ucast.Type       // "123"
str := ucast.Type[float64](3.14)  // "3.14"

func Uint8ToString

func Uint8ToString(v *uint8) string

Uint8ToString converts a uint8 to string

func Uint16ToString

func Uint16ToString(v *uint16) string

Uint16ToString converts a uint16 to string

func Uint32ToString

func Uint32ToString(v *uint32) string

Uint32ToString converts a uint32 to string

func Uint64ToString

func Uint64ToString(v *uint64) string

Uint64ToString converts a uint64 to string

func UintToString

func UintToString(v *uint) string

UintToString converts a uint to string

Types

This section is empty.

Jump to

Keyboard shortcuts

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