Go Genericsがどんなもんか試してみたかったので、これを使ってOptionの実装を書いてみました。 github.com 基本的な使い方としてはSynopsisを読んでもらえばわかると思いますが、ユーティリティとしては IsSome() IsNone() Take() TakeOr() TakeOrElse() Filter() Map() MapOr() Zip() ZipWith() Unzip() UnzipWith() あたりを取り揃えております。examplesも併せてご覧いただくとおおよその使い方の雰囲気が掴めると思います。 利用のためにはまだunstableな最新版 (go1.18) を使う必要があるので、gotipとかを使って新しい処理系を引っぱってくる必要があります。 で、GoのGenericsを使ってみた感想としてdefault valueとかconstrain