# README
サンプルリスト
このディレクトリには以下のサンプルがあります。
file | example name | note |
---|---|---|
range_over_func1.go | iters_range_over_func_1 | Go 1.23 で正式導入となった Range-Over-Func のサンプルです。(func() bool) |
range_over_func2.go | iters_range_over_func_2 | Go 1.23 で正式導入となった Range-Over-Func のサンプルです。(func(v) bool) |
range_over_func3.go | iters_range_over_func_3 | Go 1.23 で正式導入となった Range-Over-Func のサンプルです。(func(k, v) bool) |
seq.go | iters_seq | Go 1.23 で正式導入となった iter.Seq のサンプルです。 |
seq2.go | iters_seq2 | Go 1.23 で正式導入となった iter.Seq2 のサンプルです。 |
pull1.go | iters_pull | Go 1.23 で正式導入となった iter.Pull のサンプルです。 |
# Functions
Go123RangeOverFunc1 は、Go 1.23 で正式導入となった Range-Over-Func のサンプルです。
Range-Over-Func は、独自のイテレータを作成出来るようになる機能です。 以下の関数パターンがサポートされています。
- func(func() bool) : ループ変数に値を渡さないタイプ - func(func(v) bool) : 1つのループ変数に値を渡すタイプ - func(func(k, v) bool) : 2つのループ変数に値を渡すタイプ
本サンプルは、func(func() bool) (ループ変数に値を渡さないタイプ) についてのサンプルです。
# REFERENCES - https://tip.golang.org/doc/go1.23 - https://tip.golang.org/blog/range-functions - https://tip.golang.org/ref/spec#For_range - https://pkg.go.dev/[email protected] - https://zenn.dev/koya_iwamura/articles/7e7482c7222e37 - https://tech.every.tv/entry/2023/12/09/1 - https://future-architect.github.io/articles/20240129a/.
Go123RangeOverFunc2 は、Go 1.23 で正式導入となった Range-Over-Func のサンプルです。
Range-Over-Func は、独自のイテレータを作成出来るようになる機能です。 以下の関数パターンがサポートされています。
- func(func() bool) : ループ変数に値を渡さないタイプ - func(func(v) bool) : 1つのループ変数に値を渡すタイプ - func(func(k, v) bool) : 2つのループ変数に値を渡すタイプ
本サンプルは、func(func(v) bool) (1つのループ変数に値を渡すタイプ) についてのサンプルです。
# REFERENCES - https://tip.golang.org/doc/go1.23 - https://tip.golang.org/blog/range-functions - https://tip.golang.org/ref/spec#For_range - https://pkg.go.dev/[email protected] - https://zenn.dev/koya_iwamura/articles/7e7482c7222e37 - https://tech.every.tv/entry/2023/12/09/1 - https://future-architect.github.io/articles/20240129a/.
Go123RangeOverFunc3 は、Go 1.23 で正式導入となった Range-Over-Func のサンプルです。
Range-Over-Func は、独自のイテレータを作成出来るようになる機能です。 以下の関数パターンがサポートされています。
- func(func() bool) : ループ変数に値を渡さないタイプ - func(func(v) bool) : 1つのループ変数に値を渡すタイプ - func(func(k, v) bool) : 2つのループ変数に値を渡すタイプ
本サンプルは、func(func(k, v) bool) (2つのループ変数に値を渡すタイプ) についてのサンプルです。
# REFERENCES - https://tip.golang.org/doc/go1.23 - https://tip.golang.org/blog/range-functions - https://tip.golang.org/ref/spec#For_range - https://pkg.go.dev/[email protected] - https://zenn.dev/koya_iwamura/articles/7e7482c7222e37 - https://tech.every.tv/entry/2023/12/09/1 - https://future-architect.github.io/articles/20240129a/.
IterPull1 は、Go 1.23 で正式導入となった iter.Pull のサンプルです。
Range-Over-Func は、独自のイテレータを作成出来るようになる機能です。 以下の関数パターンがサポートされています。
- func(func() bool) : ループ変数に値を渡さないタイプ - func(func(v) bool) : 1つのループ変数に値を渡すタイプ - func(func(k, v) bool) : 2つのループ変数に値を渡すタイプ
Go 1.23 にて追加された iter パッケージには以下の2つの型が定義されています。
- iter.Seq[V any] - iter.Seq2[K, V any]
上はそれぞれ func(v) bool と func(k, v) bool に対応しており、カスタムイテレータを 戻り値や引数として指定したりする際に、イテレータであると利用者側に伝わりやすくなります。
iter.Pull() または iter.Pull2() は、PULL型の挙動を行う際に利用するものです。
# REFERENCES - https://tip.golang.org/doc/go1.23 - https://tip.golang.org/blog/range-functions - https://tip.golang.org/ref/spec#For_range - https://pkg.go.dev/[email protected] - https://zenn.dev/koya_iwamura/articles/7e7482c7222e37 - https://tech.every.tv/entry/2023/12/09/1 - https://future-architect.github.io/articles/20240129a/.
IterSeq は、Go 1.23 で正式導入となった iter.Seq のサンプルです。
Range-Over-Func は、独自のイテレータを作成出来るようになる機能です。 以下の関数パターンがサポートされています。
- func(func() bool) : ループ変数に値を渡さないタイプ - func(func(v) bool) : 1つのループ変数に値を渡すタイプ - func(func(k, v) bool) : 2つのループ変数に値を渡すタイプ
Go 1.23 にて追加された iter パッケージには以下の2つの型が定義されています。
- iter.Seq[V any] - iter.Seq2[K, V any]
上はそれぞれ func(v) bool と func(k, v) bool に対応しており、カスタムイテレータを 戻り値や引数として指定したりする際に、イテレータであると利用者側に伝わりやすくなります。
# REFERENCES - https://tip.golang.org/doc/go1.23 - https://tip.golang.org/blog/range-functions - https://tip.golang.org/ref/spec#For_range - https://pkg.go.dev/[email protected] - https://zenn.dev/koya_iwamura/articles/7e7482c7222e37 - https://tech.every.tv/entry/2023/12/09/1 - https://future-architect.github.io/articles/20240129a/.
IterSeq2 は、Go 1.23 で正式導入となった iter.Seq2 のサンプルです。
Range-Over-Func は、独自のイテレータを作成出来るようになる機能です。 以下の関数パターンがサポートされています。
- func(func() bool) : ループ変数に値を渡さないタイプ - func(func(v) bool) : 1つのループ変数に値を渡すタイプ - func(func(k, v) bool) : 2つのループ変数に値を渡すタイプ
Go 1.23 にて追加された iter パッケージには以下の2つの型が定義されています。
- iter.Seq[V any] - iter.Seq2[K, V any]
上はそれぞれ func(v) bool と func(k, v) bool に対応しており、カスタムイテレータを 戻り値や引数として指定したりする際に、イテレータであると利用者側に伝わりやすくなります。
# REFERENCES - https://tip.golang.org/doc/go1.23 - https://tip.golang.org/blog/range-functions - https://tip.golang.org/ref/spec#For_range - https://pkg.go.dev/[email protected] - https://zenn.dev/koya_iwamura/articles/7e7482c7222e37 - https://tech.every.tv/entry/2023/12/09/1 - https://future-architect.github.io/articles/20240129a/.
NewRegister -- このパッケージ用のサンプルを登録する mapping.Register を生成します。.