convert

package
v0.0.0-...-eec02a6 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const TimestampFormat = "2006-01-02T15:04:05Z"

TimestampFormat is a date time pattern used to convert times reported from various sources into a consistent date time formats.

Variables

This section is empty.

Functions

func Base64StringToObject

func Base64StringToObject(encodedObject string, destination any) error

func Int32ToUint64

func Int32ToUint64(v int32) (uint64, error)

Int32ToUint64 converts non-negative v to uint64.

func Int64ToInt

func Int64ToInt(v int64) (int, error)

Int64ToInt converts v to int after verifying it fits.

func Int64ToInt32

func Int64ToInt32(v int64) (int32, error)

Int64ToInt32 converts v to int32 after verifying it fits.

func Int64ToUint64

func Int64ToUint64(v int64) (uint64, error)

Int64ToUint64 converts non-negative v to uint64.

func IntToByte

func IntToByte(v int) (byte, error)

IntToByte converts v to byte after verifying it fits.

func IntToInt32

func IntToInt32(v int) (int32, error)

IntToInt32 converts v to int32 after verifying it fits.

func IntToUint64

func IntToUint64(v int) (uint64, error)

IntToUint64 converts non-negative v to uint64.

func ObjectToBase64String

func ObjectToBase64String(object any) (string, error)

func PtrToString

func PtrToString[T any](v *T) string

PtrToString converts any value into its string representation, or nil

func RedactSecretsFromString

func RedactSecretsFromString(stringToSanitize string, replacements map[string]string, useRegex bool) string

func ToBool

func ToBool(b string) bool

ToBool wraps strconv.ParseBool to suppress errors. Returns false if strconv.ParseBool would return an error.

func ToFormattedBool

func ToFormattedBool(value string) (string, error)

ToFormattedBool returns lowercase string value for a valid boolean value, else returns same value with error.

func ToInt64

func ToInt64(s string) (int64, error)

ToInt64 parses s as a base-10 int64.

func ToPositiveInt

func ToPositiveInt(s string) (int, error)

ToPositiveInt parses s into a platform-dependent int and returns an error if it is negative or out of range.

func ToPositiveInt32

func ToPositiveInt32(s string) (int32, error)

ToPositiveInt32 parses s into an int32 and returns an error if it is negative or out of range.

func ToPositiveInt64

func ToPositiveInt64(s string) (int64, error)

ToPositiveInt64 parses s into an int64 and returns an error if it is negative.

func ToPrintableBoolPtr

func ToPrintableBoolPtr(bPtr *bool) string

func ToPtr

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

ToPtr converts any value into a pointer to that value.

func ToSlicePtrs

func ToSlicePtrs[T any](slice []T) []*T

ToSlicePtrs converts a slice into a slice of pointers

func ToStringRedacted

func ToStringRedacted(structPointer interface{}, redactList []string, configVal interface{}) (out string)

ToStringRedacted identifies attributes of a struct, stringifies them such that they can be consumed by the struct stringer interface, and redacts elements specified in the redactList.

func ToTitle

func ToTitle(str string) string

ToTitle minimally replaces the deprecated strings.Title() function.

func ToUint64

func ToUint64(s string) (uint64, error)

ToUint64 parses s as a base-10 uint64.

func ToVal

func ToVal[T any](v *T) T

ToVal converts any pointer to a value, into the value. If the supplied pointer is nil, the zero value of the type is returned.

func TruncateString

func TruncateString(s string, maxLength int) string

TruncateString returns the specified string, shortened by dropping characters on the right side to the given limit.

func Uint64ToInt

func Uint64ToInt(v uint64) (int, error)

Uint64ToInt converts v to int after verifying it fits.

func Uint64ToInt32

func Uint64ToInt32(v uint64) (int32, error)

Uint64ToInt32 converts v to int32 after verifying it fits.

func Uint64ToInt64

func Uint64ToInt64(v uint64) (int64, error)

Uint64ToInt64 converts v to int64 after verifying it fits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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