{"id":13411570,"url":"https://github.com/bobg/go-generics","last_synced_at":"2026-01-11T03:35:38.359Z","repository":{"id":53799534,"uuid":"487343995","full_name":"bobg/go-generics","owner":"bobg","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-19T05:19:40.000Z","size":117,"stargazers_count":73,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T09:09:45.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bobg.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-30T17:47:19.000Z","updated_at":"2024-09-12T22:51:41.000Z","dependencies_parsed_at":"2023-12-28T16:26:27.965Z","dependency_job_id":"1c87538b-b599-4c90-ba9f-56203ac0f4eb","html_url":"https://github.com/bobg/go-generics","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fgo-generics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fgo-generics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fgo-generics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bobg%2Fgo-generics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bobg","download_url":"https://codeload.github.com/bobg/go-generics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618635,"owners_count":20320269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:14.613Z","updated_at":"2026-01-11T03:35:38.300Z","avatar_url":"https://github.com/bobg.png","language":"Go","funding_links":[],"categories":["Data Structures and Algorithms","数据结构与算法","Data Integration Frameworks"],"sub_categories":["Miscellaneous Data Structures and Algorithms","杂项数据结构和算法"],"readme":"# Go-generics - Generic slice, map, set, iterator, and goroutine utilities for Go\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bobg/go-generics/v4.svg)](https://pkg.go.dev/github.com/bobg/go-generics/v4)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bobg/go-generics/v4)](https://goreportcard.com/report/github.com/bobg/go-generics/v4)\n[![Tests](https://github.com/bobg/go-generics/actions/workflows/go.yml/badge.svg)](https://github.com/bobg/go-generics/actions/workflows/go.yml)\n[![Coverage Status](https://coveralls.io/repos/github/bobg/go-generics/badge.svg?branch=master)](https://coveralls.io/github/bobg/go-generics?branch=master)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\nThis is go-generics,\na collection of typesafe generic utilities\nfor slices, sets, and goroutine patterns in Go.\n\n# Compatibility note\n\nThis is version 4 of this library,\nfor the release of Go 1.23.\n\nEarlier versions of this library included a package,\n`iter`,\nthat defined an iterator type over several types of containers,\nand functions for operating with iterators.\nHowever, Go 1.23 defines its own, better iterator mechanism\nvia the new “range over function” language feature,\nplus [a new standard-library package](https://pkg.go.dev/iter) also called `iter`.\nThis version of the go-generics library therefore does away with its `iter` package.\nThe handy functions that `iter` contained for working with iterators\n(`Filter`, `Map`, `FirstN`, and many more)\ncan now be found in the [github.com/bobg/seqs](https://pkg.go.dev/github.com/bobg/seqs) library,\nadapted for Go 1.23 iterators.\n\n(This version of go-generics might have kept `iter` as a drop-in replacement for the standard-library package,\nbut was unable because the standard library defines two types,\n`iter.Seq[K]` and `iter.Seq2[K, V]`,\nthat go-generics would have had to reference using type aliases;\nbut Go type aliases [do not yet permit type parameters](https://github.com/golang/go/issues/46477#issuecomment-2101270785).)\n\nEarlier versions of this library included combinatorial operations in the `slices` package.\nThose have now been moved to their own library,\n[github.com/bobg/combo](https://pkg.go.dev/github.com/bobg/combo).\n\nEarlier versions of this library included a `maps` package,\nwhich was a drop-in replacement for the stdlib `maps`\n(added in Go 1.21)\nplus a few convenience functions.\nWith the advent of Go 1.23 iterators,\nthose few convenience functions are mostly redundant\n(and a couple of them − `Keys` and `Values` − conflict with new functions in the standard library),\nso `maps` has been removed.\n\nEarlier versions of this library included a `Find` method on the `set.Of[T]` type,\nfor finding some element in the set that satisfies a given predicate.\nThis method has been removed in favor of composing operations with functions from [github.com/bobg/seqs](https://pkg.go.dev/github.com/bobg/seqs).\nFor example, `s.Find(pred)` can now be written as `seqs.First(seqs.Filter(s.All(), pred))`.\n\n# Slices\n\nThe `slices` package is useful in three ways:\n\n- It encapsulates hard-to-remember Go idioms for inserting and removing elements to and from the middle of a slice;\n- It adds the ability to index from the right end of a slice using negative integers\n  (for example, Get(s, -1) is the same as s[len(s)-1]); and\n- It includes `Map`, `Filter`, and a few other such functions\n  for processing slice elements with callbacks.\n\nThe `slices` package is a drop-in replacement\nfor the `slices` package\nadded to the Go stdlib\nin [Go 1.21](https://go.dev/doc/go1.21#slices).\nThere is one difference:\nthis version of `slices`\nallows the index value passed to `Insert`, `Delete`, and `Replace`\nto be negative for counting backward from the end of the slice.\n\n# Set\n\nThe `set` package implements the usual collection of functions for sets:\n`Intersect`, `Union`, `Diff`, etc.,\nas well as member functions for adding and removing items,\nchecking for the presence of items,\nand iterating over items.\n\n# Parallel\n\nThe `parallel` package contains functions for coordinating parallel workers:\n\n- `Consumers` manages a set of N workers consuming a stream of values produced by the caller.\n- `Producers` manages a set of N workers producing a stream of values consumed by the caller.\n- `Values` concurrently produces a set of N values.\n- `Pool` manages access to a pool of concurrent workers.\n- `Protect` manages concurrent access to a protected data value.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobg%2Fgo-generics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobg%2Fgo-generics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobg%2Fgo-generics/lists"}