util

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool = false
View Source
var RaceDetectorEnabled bool = false

Functions

func Abbreviate

func Abbreviate(str string, length int) string

Abbreviate truncates a string from the beginning to the specified length. Parameters:

  • str: the input string
  • length: the maximum length to truncate to -1: return the complete string 0: return empty string >0: return the first 'length' characters, appending "..." if truncated

func CloneBytes

func CloneBytes(src []byte) []byte

new copy of the slice

func CloneBytesIf

func CloneBytesIf(src []byte, clone bool) []byte

CloneBytesIf conditionally copies a byte slice. If clone is true, it returns a new copy of the slice. If clone is false, it returns the original slice without copying. If the source slice is empty, it returns an empty slice.

func EncodeUUIDHex added in v1.0.0

func EncodeUUIDHex(dst []byte, uuid []byte)

EncodeUUIDHex encode uuid to string len(dst) >= 36, and uuid must be [16]byte

func UnsafeBytesToString

func UnsafeBytesToString(b []byte) string

func UnsafeFromBytes

func UnsafeFromBytes[T any](bs []byte) *T

func UnsafePointer

func UnsafePointer[P *T, T any](p P) unsafe.Pointer

func UnsafeSizeOf

func UnsafeSizeOf[T any]() uintptr

func UnsafeSlice

func UnsafeSlice[T any](ptr unsafe.Pointer, len int) []T

func UnsafeSliceCast

func UnsafeSliceCast[B any, A any](from []A) []B

func UnsafeSliceCastToLength

func UnsafeSliceCastToLength[B any, A any](from []A, length int) []B

func UnsafeSliceToBytes

func UnsafeSliceToBytes[T any](from []T) []byte

func UnsafeStringToBytes

func UnsafeStringToBytes(s string) []byte

func UnsafeToBytes

func UnsafeToBytes[P *T, T any](p P) []byte

func UnsafeToBytesWithLength

func UnsafeToBytesWithLength[P *T, T any](p P, length int) []byte

Wrapper of unsafe.Slice

func UnsafeUintptr

func UnsafeUintptr[P *T, T any](p P) uintptr

Types

This section is empty.

Jump to

Keyboard shortcuts

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