xstd

module
v0.0.0-...-fba16f1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0

README

xstd

A collection of generic helpers for Go.

CI Go Reference

Installation

go get spheric.cloud/xstd

Packages

This repository is organized into the following packages:

chans

Generic helpers for working with channels. Includes context-aware Offer / Poll for single sends and receives, as well as iterator-based SendSeq, RecvSeq, OfferSeq, PollSeq (and their NoError variants) to bridge channels and iter.Seq.

container/hashmap

A generic hash map keyed by a user-supplied hash and equality function, allowing non-comparable key types.

container/hashset

A generic hash set backed by a user-supplied hash and equality function, allowing non-comparable value types.

container/keymap

A generic map that derives a comparable internal key from each key via a user-supplied function, allowing non-comparable key types with O(1) lookups.

container/keyset

A generic set that derives a comparable internal key from each value via a user-supplied function, allowing non-comparable value types with O(1) membership checks.

container/list

A generic, type-safe doubly-linked list — a drop-in replacement for the standard library's container/list with full iterator support (Values, Elems).

container/orderedkeymap

A generic ordered map that derives a comparable internal key from each key via a user-supplied function and preserves insertion order.

container/orderedkeyset

A generic ordered set that derives a comparable internal key from each value via a user-supplied function and preserves insertion order.

container/orderedmap

A generic ordered map with comparable keys that preserves insertion order.

container/set

A lightweight generic set for comparable types, implemented as map[V]struct{}.

container/squeue

A generic sequential queue backed by a dynamically growing/shrinking circular slice buffer.

funcs

Generic function adapters and combinators — Identity, Const, type-casting wrappers (CastIn, CastOut, …), and more.

gen

Generic value helpers — type assertions (Cast, As, IsA), zero-value utilities (Zero, IsZero, New), and development placeholders (TODO, Stub).

iters

A rich set of helpers and adapters for Go iterators (iter.Seq / iter.Seq2):

  • SourcesOf, FromNext, FromNext2, Repeat, Repeat2, RepeatFunc, …
  • TransformsTap, Flatten, Map, FlatMap, Zip, Enumerate, Chunk, Window, …
  • SelectionUnique, Filter, Take, Skip, TakeWhile, SkipWhile, …
  • SinksAll, Any, Count, Reduce, Fold, Min, Max, Sum, ForEach, Collect, …
  • Try variants — error-aware versions of the above for iter.Seq2[V, error] sequences.
net/xhttp

Helpers for net/http — currently provides JSON for writing JSON responses with a status code.

ptrs

Utility functions for working with pointers — To, Deref, DerefOr, DerefOrZero, Map, MapRef, and iterator helpers for pointer sequences.

sets

Generic functions for working with set.SetHasAll, HasAny, Clone, Difference, Union, Equal, and more.

xconstraints

Type constraints for generic programming — Channel, Send, and Receive constraints that match any channel directionality.

xmaps

Generic functions for working with maps — Inverse, KeysByValue, GetAny, Pop, and more.

xslices

Generic functions for working with slices — Map, Flatten, Filter, Unique, Random, Collect, TryCollect, channel-to-slice helpers (CollectRecvChan, CollectPollChan), and more.

xstrings

Helper functions for working with strings — JoinSeq, WriteJoining, and Random (random string generation from a character set).

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Directories

Path Synopsis
container
list
Package list is a generic and thus type-safe version of golang's container/list.
Package list is a generic and thus type-safe version of golang's container/list.
set
net
Package ptrs provides utility functions for working with pointers.
Package ptrs provides utility functions for working with pointers.
Package sets provides utility functions for working with sets.
Package sets provides utility functions for working with sets.

Jump to

Keyboard shortcuts

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