nonstd

module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0

README

nonstd

PkgGoDev License build and test Go Report Card Coverage

A small collection of generic little helpers, deemed to be too "abstractive" (a portmaneau of abstract and distractive) to sully the stdlib. Of course, your mileage will vary widely.

nonstd is on purpose a much smaller and much less comprehensive collection compared to all the existing kitchen sinks out there.

  • sets when you're tired of map[T]bool and especially map[T]struct{} when just needing a set of Ts.
  • xiter:
    • Filter and Filter2 to filter sequences.
    • FirstOk and First2Ok: get the first element of a sequence.
    • Map transforms sequences.
    • Swap (k,v) into (v,k) sequences.
  • xmaps: Collect, CollectT where the same key maps to multiple values.
  • xslices:
    • just All the values without the pesky indices please.
    • Filter returning a new slice with only the elements passing the test function.
    • Map transforms slices.
    • Any to convert slices of other types into []any slices.
    • ReflectValues to convert an slice into a slice of Reflect.Values.
    • SortedCopy, SortedCopyFunc and StableSortedCopyFunc sort copies of slices.
    • Slice turns a list of uniformly typed elements into a slice.
  • xstrings:
    • CutWhitespace a string at the first white space.
    • JoinSpaced for joining string slice elements, ensuring there's only one space between them.
  • xslog:
    • Lazy returns a slog.Attr that evaluates its value via a function only when actually needed.
    • Error returns an "err"-named slog.Attr with the passed error value.

DevContainer

[!CAUTION]

Do not use VSCode's "Dev Containers: Clone Repository in Container Volume" command, as it is utterly broken by design, ignoring .devcontainer/devcontainer.json.

  1. git clone https://github.com/thediveo/nonstd
  2. in VSCode: Ctrl+Shift+P, "Dev Containers: Open Workspace in Container..."
  3. select nonstd.code-workspace and off you go...

Supported Go Versions

nonstd supports versions of Go that are noted by the Go release policy, that is, major versions N and N-1 (where N is the current major version).

Contributing

Please see CONTRIBUTING.md.

nonstd is Copyright 2026 Harald Albrecht, and licensed under the Apache License, Version 2.0.

Directories

Path Synopsis
Package sets provide a simple set implementation using Go Generics.
Package sets provide a simple set implementation using Go Generics.
Package xiter provides simple iterator helpers.
Package xiter provides simple iterator helpers.
Package xmaps provides non-standard convenience map functions.
Package xmaps provides non-standard convenience map functions.
Package xslices provides convenience slice functions.
Package xslices provides convenience slice functions.
Package xstrings provides convenience string functions.
Package xstrings provides convenience string functions.

Jump to

Keyboard shortcuts

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