utils

package
v0.1.0 Latest Latest
Warning

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

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

README

Utils

Common utility functions and helpers for working with Go primitives and data structures.

Packages

  • sliceutils - Utilities for working with slices (map, filter, reduce, shuffle, etc.)
  • maputils - Utilities for working with maps (transformations, merging, submap checking)
  • iterutils - Utilities for working with Go iterators (map, filter, zip, concat, etc.)
  • algebrautils - Utilities for working with algebraic structures (scalar multiplication, folding, etc.)
  • mathutils - Mathematical utilities and number operations
  • nocopy - Types to prevent copying of structs

Core Functions

  • BoolTo[T] - Convert boolean to any integer type
  • IsNil[T] - Check if a value is nil (handles pointers and interfaces)
  • LeadingZeroBytes - Count leading zero bytes in a byte slice
  • ImplementsX[X, T] - Check if a value implements an interface
  • Binomial - Compute binomial coefficients

Documentation

Overview

Package utils provides common utility functions and helpers for working with Go primitives and data structures.

See README.md for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Binomial

func Binomial(n, k int) int

Binomial computes the binomial coefficient "n choose k".

func BoolTo

func BoolTo[T constraints.Integer](b bool) T

BoolTo casts a bool to any integer type.

func ImplementsX

func ImplementsX[X, T any](v T) (X, bool)

ImplementsX checks if the given value v implements the interface X.

func IsNil

func IsNil[T any](v T) bool

IsNil returns true if the given value is nil.

func LeadingZeroBytes

func LeadingZeroBytes(b []byte) int

LeadingZeroBytes returns the count of 0x00 prefix bytes.

Types

This section is empty.

Directories

Path Synopsis
Package algebrautils provides utilities for working with algebraic structures such as monoids, groups, rings, and fields.
Package algebrautils provides utilities for working with algebraic structures such as monoids, groups, rings, and fields.
Package ioutils provides I/O helpers for Readers and Writers.
Package ioutils provides I/O helpers for Readers and Writers.
Package iterutils provides functional utilities for working with Go 1.23+ iterators (iter.Seq and iter.Seq2), enabling lazy evaluation and efficient data processing.
Package iterutils provides functional utilities for working with Go 1.23+ iterators (iter.Seq and iter.Seq2), enabling lazy evaluation and efficient data processing.
Package maputils provides utilities for working with Go maps, providing functional transformations and map operations.
Package maputils provides utilities for working with Go maps, providing functional transformations and map operations.
Package mathutils provides mathematical utility functions for cryptographic and numerical operations.
Package mathutils provides mathematical utility functions for cryptographic and numerical operations.
Package nocopy provides types to prevent copying of structs after first use, useful for ensuring proper handling of sensitive data structures.
Package nocopy provides types to prevent copying of structs after first use, useful for ensuring proper handling of sensitive data structures.
Package sliceutils provides functional utilities for working with slices in Go, providing a rich set of operations for transforming, filtering, and manipulating slice data.
Package sliceutils provides functional utilities for working with slices in Go, providing a rich set of operations for transforming, filtering, and manipulating slice data.

Jump to

Keyboard shortcuts

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