kkutil

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package kkutil provides common utility functions for various data types and operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesFromUUID

func BytesFromUUID(uuidObj uuid.UUID) []byte

BytesFromUUID converts a UUID object to its binary representation as a byte slice. It uses the UUID's MarshalBinary method to get the raw bytes. Optimized version that directly accesses UUID bytes to avoid allocation.

func CastString

func CastString(obj interface{}) *string

CastString attempts to cast an interface{} to a string pointer. Returns a pointer to the string if the cast is successful, nil otherwise.

func IsInt

func IsInt(str string) bool

IsInt checks if a string represents a valid integer. It attempts to parse the string as a 64-bit integer and returns true if successful.

func MaxTimestamp

func MaxTimestamp() int64

MaxTimestamp returns the maximum timestamp value for 32-bit systems (2^32 - 1). This represents the maximum date that can be stored in a 32-bit Unix timestamp.

func MaxTimestamp32u

func MaxTimestamp32u() uint

MaxTimestamp32u returns the maximum timestamp value as an unsigned integer. This is equivalent to MaxTimestamp but returns uint type instead of int64.

func NowUInt

func NowUInt() uint

NowUInt returns the current Unix timestamp as an unsigned integer. This is a convenience function for getting the current time in Unix format.

func SplitRemoteAddr

func SplitRemoteAddr(addr string) (ip net.IP, port string)

SplitRemoteAddr parses a network address string and extracts the IP and port components. It handles both IPv4 and IPv6 addresses with proper bracket notation for IPv6. Returns the parsed IP address and port string. If no port is found, port will be empty. Optimized version with reduced string operations and single-pass parsing.

func UnixToTime

func UnixToTime(unixSecond int64) time.Time

UnixToTime converts a Unix timestamp (seconds since epoch) to a time.Time object. The nanosecond component is set to 0.

func ZeroTimestamp

func ZeroTimestamp() int64

ZeroTimestamp returns the zero timestamp value (0) representing the Unix epoch. This is commonly used as a default or initial timestamp value.

Types

This section is empty.

Directories

Path Synopsis
Package access provides interfaces for components that support runtime reloading.
Package access provides interfaces for components that support runtime reloading.
Package hash provides time-based hashing utilities with optional encryption support.
Package hash provides time-based hashing utilities with optional encryption support.
Package hex provides utilities for hexadecimal encoding and decoding operations.
Package hex provides utilities for hexadecimal encoding and decoding operations.
Package structs provides common data structure interfaces and implementations.
Package structs provides common data structure interfaces and implementations.
Package validate provides utilities for validating various data types including IP addresses, phone numbers, email addresses, and other common formats.
Package validate provides utilities for validating various data types including IP addresses, phone numbers, email addresses, and other common formats.
Package value provides utilities for type casting and copying values using reflection.
Package value provides utilities for type casting and copying values using reflection.
Package xtype provides extended type definitions with additional utility methods.
Package xtype provides extended type definitions with additional utility methods.

Jump to

Keyboard shortcuts

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