You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extended computation library for google/cel-go. Provides additional member functions for bytes, integer, and unsigned integer types, plus math random utilities and value conversion helpers.
Returns a slice from start (inclusive) to end (exclusive)
delete(int)
bytes → bytes
Deletes the byte at the given index
delete(int, int)
bytes → bytes
Deletes a range from start to end
swap(int, int)
bytes → bytes
Swaps bytes at the two given indices
Bitwise Operations on Bytes
Function
Signature
Description
bitwise_and(bytes)
bytes → bytes
Bitwise AND between two byte sequences
bitwise_or(bytes)
bytes → bytes
Bitwise OR between two byte sequences
bitwise_xor(bytes)
bytes → bytes
Bitwise XOR between two byte sequences
bitwise_clear(bytes)
bytes → bytes
Bitwise AND-NOT (clears bits where mask is 1)
bitwise_shr(int)
bytes → bytes
Bitwise right shift (negative values shift left)
bitwise_shl(int)
bytes → bytes
Bitwise left shift (negative values shift right)
bitwise_not()
bytes → bytes
Bitwise NOT (ones-complement) on each byte
bitwise_index(int)
bytes → bytes
Returns a single-bit byte at the given bit index
bitwise_popcnt()
bytes → int
Population count (number of bits set to 1)
Bytes Conversion
Function
Signature
Description
toi(int)
bytes → int
Converts bytes to signed integer (base: 8/16/32/64)
toui(int)
bytes → uint
Converts bytes to unsigned integer (base: 8/16/32/64)
tof(int)
bytes → double
Converts bytes to floating-point (base: 32/64)
Integer Member Functions
Function
Signature
Description
bitwise_and(int)
int → int
Bitwise AND
bitwise_or(int)
int → int
Bitwise OR
bitwise_xor(int)
int → int
Bitwise XOR
bitwise_clear(int)
int → int
Bitwise AND-NOT
bitwise_shr(int)
int → int
Bitwise right shift (negative values shift left)
bitwise_shl(int)
int → int
Bitwise left shift (negative values shift right)
bitwise_not()
int → int
Bitwise NOT (ones-complement)
bitwise_index(int)
int → bytes
Returns a single-bit byte at the given bit index
to_bytes(int)
int → bytes
Converts int to bytes (base: 8/16/32/64)
Unsigned Integer Member Functions
Function
Signature
Description
bitwise_and(uint)
uint → uint
Bitwise AND
bitwise_or(uint)
uint → uint
Bitwise OR
bitwise_xor(uint)
uint → uint
Bitwise XOR
bitwise_clear(uint)
uint → uint
Bitwise AND-NOT
bitwise_shr(int)
uint → uint
Bitwise right shift (negative values shift left)
bitwise_shl(int)
uint → uint
Bitwise left shift (negative values shift right)
bitwise_not()
uint → uint
Bitwise NOT (ones-complement)
bitwise_index(int)
uint → bytes
Returns a single-bit byte at the given bit index
to_bytes(int)
uint → bytes
Converts uint to bytes (base: 8/16/32/64)
Double Member Functions
Function
Signature
Description
to_bytes(int)
double → bytes
Converts double to bytes (base: 32/64)
Cross-Type Arithmetic Member Functions
Since CEL's built-in operators (+, -, *, /, %) use trait-based singleton dispatch and cannot accept additional overloads, member functions are provided for cross-type arithmetic:
Function
Description
add(int)
Addition (int receiver)
add(uint)
Returns int
add(double)
Returns double
sub(int)
Subtraction (int receiver)
sub(uint)
Returns int
sub(double)
Returns double
mul(int)
Multiplication (int receiver)
mul(uint)
Returns int
mul(double)
Returns double
div(int)
Division (int receiver)
div(uint)
Returns int
div(double)
Returns double
mod(int)
Modulo (int receiver)
mod(uint)
Returns int
The same functions are available on uint and double receivers. Type promotion rules:
Note: These functions use math/rand and are not suitable for security-sensitive applications. Use crypto/rand for cryptographic randomness.
Value Conversion Utilities
// Convert a CEL ref.Val to a byte slicefuncVal2Bytes(val ref.Val) ([]byte, error)
// Convert a CEL ref.Val to a stringfuncVal2String(val ref.Val) (string, error)
// Convert a CEL ref.Val to a protobuf structpb.ValuefuncVal2Pb(val ref.Val) (*structpb.Value, error)