Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobg/go-generics
https://github.com/bobg/go-generics
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bobg/go-generics
- Owner: bobg
- License: mit
- Created: 2022-04-30T17:47:19.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-09T14:59:52.000Z (4 months ago)
- Last Synced: 2024-02-10T06:35:47.460Z (4 months ago)
- Language: Go
- Size: 85.9 KB
- Stars: 49
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Lists
- awesome-go - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- awesome-go - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- awesome-go-cn - go-generics - generics) (数据结构与算法 / 杂项数据结构和算法)
- awesome-go-stars - go-generics(stars: 55) - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- awesome-go-with-stars - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- repo-1316-awesome-go-cn - go-generics - generics) [![godoc][D]](https://godoc.org/github.com/bobg/go-generics) (数据结构与算法 / 杂项数据结构和算法)
- repo-1211-awesome-go-cn - go-generics - generics) [![godoc][D]](https://godoc.org/github.com/bobg/go-generics) (数据结构与算法 / 杂项数据结构和算法)
- Go-awesome - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- awesome-go - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- awesome-go-cn - go-generics - generics) (数据结构与算法 / 杂项数据结构和算法)
- awesome-go - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
- awesome-go - go-generics - Generic slice, map, set, iterator, and goroutine utilities. (Data Structures and Algorithms / Miscellaneous Data Structures and Algorithms)
README
# Go-generics - Generic slice, map, set, iterator, and goroutine utilities for Go
[![Go Reference](https://pkg.go.dev/badge/github.com/bobg/go-generics/v3.svg)](https://pkg.go.dev/github.com/bobg/go-generics/v3)
[![Go Report Card](https://goreportcard.com/badge/github.com/bobg/go-generics/v3)](https://goreportcard.com/report/github.com/bobg/go-generics/v3)
[![Tests](https://github.com/bobg/go-generics/actions/workflows/go.yml/badge.svg)](https://github.com/bobg/go-generics/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/bobg/go-generics/badge.svg?branch=master)](https://coveralls.io/github/bobg/go-generics?branch=master)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)This is go-generics,
a collection of typesafe generic utilities
for slices, maps, sets, iterators, and goroutine patterns in Go.# Slices
The `slices` package is useful in three ways:
- It encapsulates hard-to-remember Go idioms for inserting and removing elements to and from the middle of a slice;
- It adds the ability to index from the right end of a slice using negative integers
(for example, Get(s, -1) is the same as s[len(s)-1]); and
- It includes `Map`, `Filter`, and a few other such functions
for processing slice elements with callbacks.It also includes combinatorial operations:
`Permutations`, `Combinations`, and `CombinationsWithReplacement`.The `slices` package is a drop-in replacement
for the `slices` package
added to the Go stdlib
in [Go 1.21](https://go.dev/doc/go1.21#slices).
There is one difference:
this version of `slices`
allows the index value passed to `Insert`, `Delete`, and `Replace`
to be negative for counting backward from the end of the slice.# Maps
The `maps` package has a few convenience functions
for duplicating, inverting, constructing, and iterating over maps,
as well as for testing their equality.The `maps` package is a drop-in replacement
for the `maps` package
added to the Go stdlib
in [Go 1.21](https://go.dev/doc/go1.21#maps).# Set
The `set` package implements the usual collection of functions for sets:
`Intersect`, `Union`, `Diff`, etc.,
as well as member functions for adding and removing items,
checking for the presence of items,
and iterating over items.# Iter
The `iter` package implements efficient, typesafe iterators
that can convert to and from Go slices, maps, and channels,
and produce iterators over the values from function calls and goroutines.
There is also an iterator over the results of a SQL query;
the usual collection of functions on iterators
(`Filter`, `Map`, `Concat`, `Accum`, etc.).# Parallel
The `parallel` package contains functions for coordinating parallel workers:
- `Consumers` manages a set of N workers consuming a stream of values produced by the caller.
- `Producers` manages a set of N workers producing a stream of values consumed by the caller.
- `Values` concurrently produces a set of N values.
- `Pool` manages access to a pool of concurrent workers.
- `Protect` manages concurrent access to a protected data value.