// the find
mattn/go-generics-example
Example code for Go generics
A grab-bag of ~40 tiny standalone Go programs, each demonstrating one generics feature or pattern (constraints, tuples, functional options, reduce/filter/map, reflection, binary size, benchmarks). It's for someone learning Go generics syntax and mechanics, not for pulling in as a dependency.
Each example lives in its own directory with its own go.mod, so they build and run in isolation without cross-contamination. Coverage goes beyond toy syntax demos into things people actually ask about, like a benchmark comparing generic vs non-generic performance and a binary-size comparison of generic builds. Written by mattn, and the README links out to real third-party generics libraries (samber/lo, Code-Hex/go-generics-cache) for further reading once you've seen the basics.
No tests anywhere except the benchmark folder, most examples are a bare main.go you run and eyeball output from, nothing asserts correctness. Last push was 2023-07-02, so it predates stdlib additions like the slices and maps packages that generics enabled, meaning newer idiomatic patterns are missing. There's no per-example README explaining what each one is showing or why, directory names like 'byteseq' or 'underlying' are the only clue to intent. No CI, no license file beyond a mention in the README, and no indication these examples are kept current against newer Go versions.