Skip to content

package klib

import "kaiju/klib"

Constants

ISO8601

"2006-01-02T15:04:05Z"

Functions

AppendUnique[T comparable]

func AppendUnique[T comparable](slice []T, values ...T) []T

BinaryRead

func BinaryRead(r io.Reader, data any)

BinaryReadLen

func BinaryReadLen(r io.Reader) (int32, error)

BinaryReadString

func BinaryReadString(r io.Reader) (string, error)

BinaryReadVar[T any]

func BinaryReadVar[T any](r io.Reader) (T, error)

BinaryReadVarSlice[T any]

func BinaryReadVarSlice[T any](r io.Reader) ([]T, error)

BinaryWrite

func BinaryWrite(w io.Writer, data any)

BinaryWriteMap[K comparable, V any]

func BinaryWriteMap[K comparable, V any](w io.Writer, data map[K]V)

BinaryWriteMapLen[K comparable, V any]

func BinaryWriteMapLen[K comparable, V any](w io.Writer, data map[K]V)

BinaryWriteSlice[T any]

func BinaryWriteSlice[T any](w io.Writer, data []T)

BinaryWriteSliceLen[T any]

func BinaryWriteSliceLen[T any](w io.Writer, data []T)

BinaryWriteString

func BinaryWriteString(w io.Writer, str string)

ByteSliceToFloat32Slice

func ByteSliceToFloat32Slice(data []byte) []float32

ByteSliceToUInt16Slice

func ByteSliceToUInt16Slice(data []byte) []uint16

Clamp[T cmp.Ordered]

func Clamp[T cmp.Ordered](current, minimum, maximum T) T

Contains[T comparable]

func Contains[T comparable](slice []T, item T) bool

ConvertByteSliceType[T any]

func ConvertByteSliceType[T any](slice []byte) []T

Decrypt

func Decrypt(encryptedData []byte, key []byte) ([]byte, error)

DelayCall

func DelayCall(d time.Duration, f func(), ctx context.Context)

Encrypt

func Encrypt(rawData []byte, key []byte) ([]byte, error)

ExeExtension

func ExeExtension() string

FindFirstZeroInByteArray

func FindFirstZeroInByteArray(arr []byte) int

FloatEquals[T Float]

func FloatEquals[T Float](a, b T) bool

InterfaceUnderlyingPointer[T any]

func InterfaceUnderlyingPointer[T any](s T) unsafe.Pointer

JsonDecode[T any]

func JsonDecode[T any](decoder *json.Decoder, container *T) error

MM2PX[T Number]

func MM2PX[T Number](pixels, mm, targetMM T) T

MapKeys[T comparable, U any]

func MapKeys[T comparable, U any](m map[T]U) []T

MapValues[T comparable, U any]

func MapValues[T comparable, U any](m map[T]U) []U

Memcpy

func Memcpy(dst unsafe.Pointer, src unsafe.Pointer, size uint64)

Must

func Must(err error)

MustReturn[T any]

func MustReturn[T any](ret T, err error) T

MustReturn2[T, U any]

func MustReturn2[T, U any](ret1 T, ret2 U, err error) (T, U)

NotYetImplemented

func NotYetImplemented(issueId int)

OpenWebsite

func OpenWebsite(url string)

RemoveUnordered[T any]

func RemoveUnordered[T any](slice []T, idx int) []T

ReplaceStringRecursive

func ReplaceStringRecursive(s string, old string, new string) string

Should

func Should(err error) bool

ShouldReturn[T any]

func ShouldReturn[T any](ret T, err error) T

Shuffle[T any]

func Shuffle[T any](slice []T, rng *rand.Rand)

SizedStructToByteArray

func SizedStructToByteArray(s unsafe.Pointer, size int) []byte

StructSliceToByteArray[T any]

func StructSliceToByteArray[T any](s []T) []byte

StructToByteArray[T any]

func StructToByteArray[T any](s T) []byte

TickerWait

func TickerWait(interval, limit time.Duration, condition func() bool) bool

ToUnixPath

func ToUnixPath(path string) string

Trace

func Trace(message string)

TraceString

func TraceString(message string) string

TraceStrings

func TraceStrings(message string, skip int) []string

Types

Complex

interface

type Complex interface {
    ~complex64 | ~complex128
}

ErrorList

struct

type ErrorList struct {
    Errors []error
}

NewErrorList

func NewErrorList() ErrorList

ErrorList.AddAny

func (e *ErrorList) AddAny(err error)

ErrorList.Any

func (e *ErrorList) Any() bool

ErrorList.First

func (e *ErrorList) First() error

Float

interface

type Float interface {
    ~float32 | ~float64
}

Integer

interface

type Integer interface {
    Signed | Unsigned
}

Number

interface

type Number interface {
    Integer | Float
}

Ordered

interface

type Ordered interface {
    Integer | Float | ~string
}

Serializable

interface

type Serializable interface {
    Serialize(stream io.Writer)
    Deserialize(stream io.Reader)
}

Signed

interface

type Signed interface {
    ~int | ~int8 | ~int16 | ~int32 | ~int64
}

Unsigned

interface

type Unsigned interface {
    ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}