Documentation
¶
Overview ¶
Package iters -- Go 1.23 で追加された iterパッケージとRange-Over-Func機能についてサンプルが配置されています.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Go123RangeOverFunc1 ¶
func Go123RangeOverFunc1() error
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/iter@go1.23.3
- https://zenn.dev/koya_iwamura/articles/7e7482c7222e37
- https://tech.every.tv/entry/2023/12/09/1
- https://future-architect.github.io/articles/20240129a/
func Go123RangeOverFunc2 ¶
func Go123RangeOverFunc2() error
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/iter@go1.23.3
- https://zenn.dev/koya_iwamura/articles/7e7482c7222e37
- https://tech.every.tv/entry/2023/12/09/1
- https://future-architect.github.io/articles/20240129a/
func Go123RangeOverFunc3 ¶
func Go123RangeOverFunc3() error
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/iter@go1.23.3
- https://zenn.dev/koya_iwamura/articles/7e7482c7222e37
- https://tech.every.tv/entry/2023/12/09/1
- https://future-architect.github.io/articles/20240129a/
func IterPull1 ¶ added in v0.5.34
func IterPull1() error
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/iter@go1.23.3
- https://zenn.dev/koya_iwamura/articles/7e7482c7222e37
- https://tech.every.tv/entry/2023/12/09/1
- https://future-architect.github.io/articles/20240129a/
func IterSeq ¶
func IterSeq() error
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/iter@go1.23.3
- https://zenn.dev/koya_iwamura/articles/7e7482c7222e37
- https://tech.every.tv/entry/2023/12/09/1
- https://future-architect.github.io/articles/20240129a/
func IterSeq2 ¶
func IterSeq2() error
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/iter@go1.23.3
- https://zenn.dev/koya_iwamura/articles/7e7482c7222e37
- https://tech.every.tv/entry/2023/12/09/1
- https://future-architect.github.io/articles/20240129a/
func NewRegister ¶
NewRegister -- このパッケージ用のサンプルを登録する mapping.Register を生成します。
Types ¶
This section is empty.