Documentation
¶
Index ¶
- func BytesRefToUUIDRef(byteDataRef *[]byte) *uuid.UUID
- func BytesToUUID(byteData []byte) uuid.UUID
- func CastTo[T any](value any) (T, bool)
- func ConvertUUIDToBytes(uuidVal uuid.UUID) []byte
- func ConvertUUIDToBytesRef(uuidRef *uuid.UUID) *[]byte
- func CreateRef[T any](value T) *T
- func FloatToPgClean(val float64, places int) pgtype.Numeric
- func FloatToPgFixed(val float64, places int) pgtype.Numeric
- func FloatToPgNumeric(val float64, opts ...DecimalOpt) pgtype.Numeric
- func FloatToPgWhole(val float64) pgtype.Numeric
- func MillisRefToTimeRef(millisRef *int64) *time.Time
- func MillisToTime(millis int64) time.Time
- func ParseToPgTypeInterval(input string) pgtype.Interval
- func ToJSONBAny(v any) []byte
- func ToLanguageTag(l LanguageTag) language.Tag
- func ToPgTime(t time.Time) pgtype.Time
- func ToPgType[T PgType](value any, opts ...DecimalOpt) (T, error)
- func ToPgTypeBool(value bool) pgtype.Bool
- func ToPgTypeDate(t time.Time) pgtype.Date
- func ToPgTypeFloat8(value float64) pgtype.Float8
- func ToPgTypeInt2(value int16) pgtype.Int2
- func ToPgTypeInt4(value int32) pgtype.Int4
- func ToPgTypeInt8(value int64) pgtype.Int8
- func ToPgTypeNil[T PgType]() T
- func ToPgTypeText(value string) pgtype.Text
- func ToPgTypeTimestamp(value time.Time) pgtype.Timestamp
- func ToPgTypeTimestamptz(value time.Time) pgtype.Timestamptz
- func ToPgTypeUUID(u uuid.UUID) pgtype.UUID
- func ToUUID(p pgtype.UUID) (uuid.UUID, error)
- type Action
- type Bool
- type BusinessID
- type Byte
- type CodecType
- type ComponentErrorType
- type ContentType
- type CorrelationID
- type DBType
- type DecimalConfig
- type DecimalOpt
- type EmptyCheck
- type ErrorCode
- type Field
- type Float32
- type Float64
- type IDType
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type Key
- type LanguageTag
- type LogMode
- type Milliseconds
- type OrgID
- type PgType
- type Protocol
- type RequestID
- type ResponseErrorType
- type Rune
- type Service
- type Status
- type String
- type StringConstant
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
- type UserID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesRefToUUIDRef ¶
BytesRefToUUIDRef converts a byte slice pointer to a UUID pointer.
func BytesToUUID ¶
BytesToUUID converts a byte slice to a UUID.
func CastTo ¶
CastTo is a generic function to safely cast a value to a specific type. It returns the cast value and a boolean indicating whether the cast was successful. CastTo tries to cast or convert any value to the given type T.
func ConvertUUIDToBytes ¶
ConvertUUIDToBytes converts a UUID to a byte slice.
func ConvertUUIDToBytesRef ¶
ConvertUUIDToBytesRef converts a UUID pointer to a byte slice pointer.
func CreateRef ¶
func CreateRef[T any](value T) *T
CreateRef generates a pointer for any given data.
func FloatToPgClean ¶
FloatToPgClean trims decimals for integers and enforces precision
func FloatToPgFixed ¶
FloatToPgFixed converts with exact decimal precision
func FloatToPgNumeric ¶
func FloatToPgNumeric(val float64, opts ...DecimalOpt) pgtype.Numeric
FloatToPgNumeric converts a float64 into pgtype.Numeric using configurable precision rules
func FloatToPgWhole ¶
FloatToPgWhole ensures integers remain cleanly formatted
func MillisRefToTimeRef ¶
MillisRefToTimeRef converts a milliseconds pointer to a time.Time pointer.
func MillisToTime ¶
MillisToTime converts milliseconds to a time.Time value.
func ParseToPgTypeInterval ¶
ParseInterval converts a human-readable duration string into pgtype.Interval. Supports formats like "30s", "45 sec", "2 minutes", etc.
func ToJSONBAny ¶
ToJSONBAny marshals v to JSON and returns the resulting bytes suitable for JSONB storage. If v is nil or marshaling fails, it returns nil.
func ToLanguageTag ¶
func ToLanguageTag(l LanguageTag) language.Tag
Convert LanguageTag to language.Tag
func ToPgTime ¶
ToPgTime converts t to a pgtype.Time representing the number of microseconds since midnight and marks it invalid if t is the zero time.
When t is not the zero value, Microseconds is set to the total microseconds elapsed since midnight (hours, minutes, seconds, and nanoseconds converted) and Valid is true. When t is zero, Valid is false.
func ToPgType ¶
func ToPgType[T PgType](value any, opts ...DecimalOpt) (T, error)
ToPgType converts a Go value into a specific pgtype, constrained by PgType.
func ToPgTypeBool ¶
ToPgTypeBool converts a bool to pgtype.Bool.
func ToPgTypeDate ¶
ToPgTypeDate converts t to a pgtype.Date; if t is the zero time the returned Date has Valid set to false.
func ToPgTypeFloat8 ¶
ToPgTypeFloat8 converts a float64 to pgtype.Float8.
func ToPgTypeInt2 ¶
ToPgTypeInt2 converts an int value to pgtype.Int2 (PostgreSQL INTEGER).
func ToPgTypeInt4 ¶
ToPgTypeInt4 converts an int to pgtype.Int4.
func ToPgTypeInt8 ¶
ToPgTypeInt8 converts an int value to pgtype.Int2 (PostgreSQL INTEGER).
func ToPgTypeNil ¶
func ToPgTypeNil[T PgType]() T
ToPgTypeNil returns the zero value of the specified pgtype T, which can be used to represent a NULL/invalid value for that PostgreSQL type.
func ToPgTypeText ¶
ToPgTypeText converts the provided string into a pgtype.Text for PostgreSQL. It returns a Text with Valid set to false when the input is empty or contains only whitespace; otherwise it sets String to the input and Valid to true.
func ToPgTypeTimestamp ¶
ToPgTypeTimestamp converts the provided time.Time into a pgtype.Timestamp and marks the result invalid when the input is the zero time value.
func ToPgTypeTimestamptz ¶
func ToPgTypeTimestamptz(value time.Time) pgtype.Timestamptz
ToPgTypeTimestamptz converts a time.Time to a pgtype.Timestamptz, marking the result invalid if the input is the zero time.
func ToPgTypeUUID ¶
ToPgTypeUUID converts a uuid.UUID to a pgtype.UUID, treating uuid.Nil as a NULL value. If u is uuid.Nil the returned pgtype.UUID has Valid set to false; otherwise Bytes is set to u and Valid is true.
Types ¶
type BusinessID ¶
BusinessID represents a business ID.
func (BusinessID) String ¶
func (e BusinessID) String() string
String returns the string representation of the BusinessID.
type CodecType ¶
type CodecType string
CodecType defines the type of encoder (e.g., JSON, XML).
func (CodecType) ToUpperCase ¶
Method to convert string to uppercase
type ComponentErrorType ¶
type ComponentErrorType string
ComponentErrorType represents the type of component error.
func (ComponentErrorType) String ¶
func (e ComponentErrorType) String() string
String returns the string representation of the ComponentErrorType.
type ContentType ¶
type ContentType string
ContentType defines the type for a ContentType.
func (ContentType) String ¶
func (c ContentType) String() string
Method to convert ContentType Type to string
type CorrelationID ¶
type CorrelationID string
CorrelationID represents a correlation ID.
func (CorrelationID) String ¶
func (c CorrelationID) String() string
String returns the string representat ion of the CorrelationID.
type DecimalConfig ¶
type DecimalConfig struct {
Places int // default: 3
TrimIntegers bool // omit decimals for whole numbers
MinPlaces int // lower bound on precision
MaxPlaces int // upper bound on precision
}
DecimalConfig defines configuration for FloatToPgNumeric
type DecimalOpt ¶
type DecimalOpt func(*DecimalConfig)
DecimalOpt modifies DecimalConfig
func Limit ¶
func Limit(min, max int) DecimalOpt
Limit sets the minimum and maximum precision bounds
type EmptyCheck ¶
type EmptyCheck interface {
IsEmpty() bool
}
EmptyCheck defines an interface for checking if a value is empty.
type Key ¶
type Key string
key defines the type for a key.
func (Key) ToEd25519PrivateKey ¶
func (e Key) ToEd25519PrivateKey() ed25519.PrivateKey
Method to convert Key Type to Ed25519PrivateKey
func (Key) ToEd25519PublicKey ¶
Method to convert Key Type to Ed25519PublicKey
type LanguageTag ¶
Implement EmptyCheck for common types
func (LanguageTag) IsEmpty ¶
func (l LanguageTag) IsEmpty() bool
IsEmpty checks if the language tag is empty
type Milliseconds ¶
type Milliseconds int64
Milliseconds represents a duration in milliseconds.
func (Milliseconds) Int64 ¶
func (e Milliseconds) Int64() int64
Int64 returns the int64 representation of the Milliseconds.
type OrgID ¶
func (OrgID) MarshalJSON ¶
func (*OrgID) UnmarshalJSON ¶
type PgType ¶
type PgType interface {
pgtype.Int2 |
pgtype.Int4 |
pgtype.Int8 |
pgtype.Text |
pgtype.Bool |
pgtype.Float8 |
pgtype.Timestamp |
pgtype.Timestamptz |
pgtype.UUID |
pgtype.Date |
pgtype.Interval |
pgtype.Numeric
}
PgType is a constraint that lists supported pgtype structs.
type ResponseErrorType ¶
type ResponseErrorType string
ResponseErrorType represents the type of response error.
func (ResponseErrorType) String ¶
func (e ResponseErrorType) String() string
String returns the string representation of the ResponseErrorType.
type StringConstant ¶
type StringConstant string
StringConstant represents a constant string value.
func (StringConstant) String ¶
func (s StringConstant) String() string
String returns the string representation of the StringConstant.
type UserID ¶
UserID represents a user ID.