lox

package
v0.1.19 Latest Latest
Warning

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

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

Documentation

Overview

Package lox contains local extensions to the github.com/samber/lo package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRC32

func CRC32(buf []byte) int

CRC32 returns the CRC32 checksum of buf as an int

func Chunk

func Chunk[T any](size int, iter iter.Seq[T]) iter.Seq[[]T]

Chunk breaks the elements of iter into chunks of size, returning an iterator over the chunks.

func Coalesce

func Coalesce[T comparable](v ...T) (result T)

Coalesce returns the first non-empty arguments. Arguments must be comparable.

func Elide

func Elide(s string, maxLen int) string

Elide returns a string that is at most maxLen characters long. If the string is longer than maxLen, it will be truncated and "..." will be appended to the end. If maxLen is less than 3, it will be set to 3. If the string is shorter than or equal to maxLen, it will be returned

func Filter

func Filter[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) Slice

Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for. Play: https://go.dev/play/p/Apjg3WeSi7K

func HMACSHA256

func HMACSHA256(key []byte, value []byte) []byte

HMACSHA256 returns the HMAC-SHA256 hash of value using key

func Index

func Index[T any](iter iter.Seq[T]) iter.Seq2[int, T]

Index returns an iterator over the elements of iter, yielding the index and the element.

func Last

func Last[T any](collection []T) T

Last returns the last element of a collection or zero value if empty.

func Map

func Map[T any, R any](collection []T, iteratee func(item T) R) []R

Map manipulates a slice and transforms it to a slice of another type. Play: https://go.dev/play/p/OkPcYAhBo0D

func SHA256

func SHA256(buf []byte) []byte

SHA256 returns the SHA256 hash of buf as a byte slice

func SHA512

func SHA512(buf []byte) []byte

SHA512 returns the SHA512 hash of buf as a byte slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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