conversion

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToMap added in v0.0.2

func AnyToMap(data any) (map[string]any, error)

func BoolToString

func BoolToString(val bool) string

BoolToString converts a boolean to a string

func EstimateTokenCount added in v1.2.0

func EstimateTokenCount(content string) int

EstimateTokenCount calculates the total number of tokens from a string Uses a rough approximation: 1 token ≈ 4 characters

func FloatToString

func FloatToString(num float64) string

FloatToString converts a float64 to a string

func FromJSON added in v0.0.2

func FromJSON[T any](jsonString string) (T, error)

FromJSON converts a JSON string to a struct of type T

func IntToString

func IntToString(num int) string

IntToString converts an integer to a string

func JsonStringToMap added in v0.0.2

func JsonStringToMap(jsonString string) (map[string]any, error)

JsonStringToMap parses a JSON string and converts it to a map with string keys and any values

func PrettyPrint added in v1.1.2

func PrettyPrint(jsonStr string) (string, error)

func StringToBool

func StringToBool(str string) bool

func StringToBoolErr

func StringToBoolErr(str string) (bool, error)

StringToBoolErr converts a string to a boolean and returns an error if conversion fails

func StringToBoolOrDefault

func StringToBoolOrDefault(str string, defaultValue bool) bool

StringToBoolOrDefault converts a string to a boolean, returning a custom default value if conversion fails

func StringToFloat

func StringToFloat(str string) float64

func StringToFloatErr

func StringToFloatErr(str string) (float64, error)

StringToFloatErr converts a string to a float64 and returns an error if conversion fails

func StringToFloatOrDefault

func StringToFloatOrDefault(str string, defaultValue float64) float64

StringToFloatOrDefault converts a string to a float64, returning a custom default value if conversion fails

func StringToInt

func StringToInt(str string) int

func StringToIntErr

func StringToIntErr(str string) (int, error)

StringToIntErr converts a string to an integer and returns an error if conversion fails

func StringToIntOrDefault

func StringToIntOrDefault(str string, defaultValue int) int

StringToIntOrDefault converts a string to an integer, returning a custom default value if conversion fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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