Releases: bobg/go-generics
Version 4 API, take two
What's Changed
This is the new official release of the v4 API. Callers should not use v4.0.0, which is now retracted, because of an incompatible change: removing the ~func
type parameters from functions in parallel
.
This release updates go-generics to new major version 4 for the release of Go 1.23.
This release removes the iter
and maps
packages.
The iter.Of[T]
type was made obsolete with the introduction of Go 1.23 iterators. The functionality previously available for iter.Of[T]
iterators has now been replicated for Go 1.23 iterators in the github.com/bobg/seqs package (qv).
Operations in other subpackages that produced or consumed iter.Of[T]
iterators now use Go's standard iter.Seq[T]
iterators.
The maps
package was mostly redundant with the Go standard library.
Additionally, combinatorial operations previously found in the slices
package have now moved to github.com/bobg/combo.
Full Changelog: v3.7.0...v4.1.0
Version 4 API for Go 1.23
This release updates go-generics to new major version 4 for the release of Go 1.23. Note: this release is retracted. Callers should use v4.1.0 or later.
This release removes the iter
and maps
packages.
The iter.Of[T]
type was made obsolete with the introduction of Go 1.23 iterators. The functionality previously available for iter.Of[T]
iterators has now been replicated for Go 1.23 iterators in the github.com/bobg/seqs package (qv).
Operations in other subpackages that produced or consumed iter.Of[T]
iterators now use Go's standard iter.Seq[T]
iterators.
The maps
package was mostly redundant with the Go standard library.
Additionally, combinatorial operations previously found in the slices
package have now moved to github.com/bobg/combo.
Full Changelog: v3.7.0...v4.0.0
Add Find method to set.Of[T]
Scalar types for iter.SQL[T]
This release adds the ability to use scalar types as the type parameter to iter.SQL (which previously could operate only on structs).
Full Changelog: v3.5.0...v3.6.0
Adapters from Go 1.23 iterators to iter.Of
This release adds iter.FromSeq
, iter.FromSeq2
, iter.FromSeqContext
, and iter.FromSeq2Context
, for adapting Go 1.23 iterators to iter.Of
.
New function iter.LongLines
This release adds iter.LongLines
, which produces an iterator of io.Reader
s over the lines of some input. Unlike iter.Lines
(and unlike bufio.Scanner
, on which iter.Lines
is based), LongLines
is not subject to a line-length limitation.
Update for Go 1.22
This release updates go-generics for Go 1.22.
It adds slices.Concat
so the slices
package remains a drop-in replacement for the standard-library version.
It also adds the functions iter.All
, iter.AllCount
, iter.AllPairs
, and the types iter.Seq
and iter.Seq2
. These allow creating Go 1.23-style iterators from an iter.Of
. A preview of Go 1.23 iterators is available in Go 1.22 by building with GOEXPERIMENT=rangefunc
. When that is set, this module also defines iter.Pull
and iter.Pull2
. For more information about Go 1.23 iterators, see Rangefunc Experiment.
V3 API
Version 2 of this module relied on golang.org/x/exp, which had incompatible changes made in the lead-up to Go 1.21, requiring some function signatures to change. So here's version 3, with those new signatures and other adaptations. The dependency on golang.org/x/exp is removed and the minimum Go version is now 1.21.
V2 API
What's Changed
This update to the API has parity with golang.org/x/exp/slices and golang.org/x/exp/maps (which will become part of the stdlib in Go 1.21).
Generic declarations are more correct. Whereas in v1 we had e.g.:
func Get[T any](s []T, idx int) T { ... }
(which allows Get
to take a []T
only)
now we have:
func Get[S ~[]T, T any](s S, idx int) T { ... }
(which allows Get
to take a []T
and any type defined as []T
).
Combinatorics functions are now in the slices
package.
Several functions taking callbacks now have a Function
form and a Functionx
("extended") form. The first one takes a simpler callback for greater ergonomics. The second one takes a more thorough callback. For example, the callback in slices.Map
takes a single argument of type T
and returns a single value of type U
, while the callback in slices.Mapx
takes an index and a T
, and returns a U
and an error.
Pull requests are now checked by golangci-lint.
Full Changelog: v1.7.2...v2.1.1
(Note: this is v2.1.1 of this module. An earlier v2.0.0 has been retracted.)
Add combinatorial functions
This release adds Permutations
, Combinations
, and CombinationsWithReplacement
to the iter
package.