convert

package
v0.0.0-...-96d9297 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func BoolMap

func BoolMap(src map[string]bool) map[string]*bool

BoolMap converts a string map of bool values into a string map of bool pointers

func BoolSlice

func BoolSlice(src []bool) []*bool

BoolSlice converts a slice of bool values into a slice of bool pointers

func BoolValue

func BoolValue(v *bool) bool

BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.

func BoolValueMap

func BoolValueMap(src map[string]*bool) map[string]bool

BoolValueMap converts a string map of bool pointers into a string map of bool values

func BoolValueSlice

func BoolValueSlice(src []*bool) []bool

BoolValueSlice converts a slice of bool pointers into a slice of bool values

func ByteToFloat64

func ByteToFloat64(bytes []byte) float64

ByteToFloat64 convert byte to float64

func ConvertBig5ToUTF8

func ConvertBig5ToUTF8(s string) string

ConvertBig5ToUTF8 converts a string encoded in Big5 to UTF-8 encoding. It takes a string `s` as input and returns the UTF-8 encoded string. If an error occurs during the conversion, it prints an error message and returns the original string.

Parameters:

  • s: The input string encoded in Big5.

Returns:

  • The UTF-8 encoded string, or the original string if an error occurs.

func Float64

func Float64(v float64) *float64

Float64 returns a pointer to the float64 value passed in.

func Float64Map

func Float64Map(src map[string]float64) map[string]*float64

Float64Map converts a string map of float64 values into a string map of float64 pointers

func Float64Slice

func Float64Slice(src []float64) []*float64

Float64Slice converts a slice of float64 values into a slice of float64 pointers

func Float64ToByte

func Float64ToByte(f float64) []byte

Float64ToByte convert float64 to byte ref: https://stackoverflow.com/questions/43693360/convert-float64-to-byte-array

func Float64Value

func Float64Value(v *float64) float64

Float64Value returns the value of the float64 pointer passed in or 0 if the pointer is nil.

func Float64ValueMap

func Float64ValueMap(src map[string]*float64) map[string]float64

Float64ValueMap converts a string map of float64 pointers into a string map of float64 values

func Float64ValueSlice

func Float64ValueSlice(src []*float64) []float64

Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values

func FromPtr

func FromPtr[T any](ptr *T) T

FromPtr takes a pointer to a value and returns the value itself. If the pointer is nil, it returns the zero value of the type.

T: The type of the value being dereferenced. ptr: The pointer to the value.

Returns the value pointed to by the pointer, or the zero value if the pointer is nil.

func Int

func Int(v int) *int

Int returns a pointer to the int value passed in.

func Int64

func Int64(v int64) *int64

Int64 returns a pointer to the int64 value passed in.

func Int64Map

func Int64Map(src map[string]int64) map[string]*int64

Int64Map converts a string map of int64 values into a string map of int64 pointers

func Int64Slice

func Int64Slice(src []int64) []*int64

Int64Slice converts a slice of int64 values into a slice of int64 pointers

func Int64Value

func Int64Value(v *int64) int64

Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.

func Int64ValueMap

func Int64ValueMap(src map[string]*int64) map[string]int64

Int64ValueMap converts a string map of int64 pointers into a string map of int64 values

func Int64ValueSlice

func Int64ValueSlice(src []*int64) []int64

Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values

func IntMap

func IntMap(src map[string]int) map[string]*int

IntMap converts a string map of int values into a string map of int pointers

func IntSlice

func IntSlice(src []int) []*int

IntSlice converts a slice of int values into a slice of int pointers

func IntValue

func IntValue(v *int) int

IntValue returns the value of the string pointer passed in or "" if the pointer is nil.

func IntValueMap

func IntValueMap(src map[string]*int) map[string]int

IntValueMap converts a string map of int pointers into a string map of int values

func IntValueSlice

func IntValueSlice(src []*int) []int

IntValueSlice converts a slice of int pointers into a slice of int values

func MD5Hash

func MD5Hash(text string) string

MD5Hash for md5 hash string

func SnakeCasedName

func SnakeCasedName(name string) string

SnakeCasedName convert String into Snake Case ex: FooBar -> foo_bar

func String

func String(v string) *string

String returns a pointer to the string value passed in.

func StringMap

func StringMap(src map[string]string) map[string]*string

StringMap converts a string map of string values into a string map of string pointers

func StringSlice

func StringSlice(src []string) []*string

StringSlice converts a slice of string values into a slice of string pointers

func StringValue

func StringValue(v *string) string

StringValue returns the value of the string pointer passed in or "" if the pointer is nil.

func StringValueMap

func StringValueMap(src map[string]*string) map[string]string

StringValueMap converts a string map of string pointers into a string map of string values

func StringValueSlice

func StringValueSlice(src []*string) []string

StringValueSlice converts a slice of string pointers into a slice of string values

func TitleCasedName

func TitleCasedName(name string) string

TitleCasedName convert String into title cased ex: foo_bar -> FooBar

func ToBool

func ToBool(value interface{}) bool

ToBool convert any type to boolean

func ToFloat

func ToFloat(value interface{}) interface{}

ToFloat convert any type to float

func ToInt

func ToInt(value interface{}) interface{}

ToInt convert any type to int

func ToPtr

func ToPtr[T any](value T) *T

ToPtr takes a value of any type and returns a pointer to that value. This is useful for converting a value to a pointer in a generic way.

T: The type of the value being converted. value: The value to be converted to a pointer.

Returns a pointer to the provided value.

func ToString

func ToString(value interface{}) string

ToString convert any type 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