Note
This repository is archived and no longer maintained.
It was a collection of experiments and demos exploring the Go 2 generics design (type parameters and type sets) before generics landed in the language. Generics shipped in Go 1.18 (March 2022), and the packages prototyped here now have official homes:
constraints,slices,maps— seegolang.org/x/expand the standard libraryslicesandmapspackages (Go 1.21+).
The content is kept for historical reference only. For up-to-date guidance, use the standard library and the official tutorials.
A chunk of demos for Go generics design (based on type parameters and type sets).
See the official implementation here.
See the official implementation here.
See the official implementation here.
This package is from the following discussions:
- golang/go#47331 proposal: container/set: new package to provide a generic set type (discussion)
See a possible implementation here.
- golang/go#47657 proposal: sync, sync/atomic: add PoolOf, MapOf, ValueOf
- golang/go#47632 proposal: container/heap: add Heap, a heap backed by a slice
- golang/go#47619 proposal: generic functions in the sort package
See folders in this repository.
- https://go.dev/issue/45639
- https://go.dev/issue/51338
- sync/*
- notsupport/*
Here are some documents to get familiar with the spirit of generics:
- Changkun Ou. A Summary of Go Generics Research 2020.08. Last Updates: 2021.08.
- Changkun Ou. Go 2 Generics: Type Parameters. https://changkun.de/s/go2generics/.
BSD-2-Clause
Copyright © 2020-2021 Changkun Ou