go/doc/next/6-stdlib/99-minor/reflect/66631.md
Quentin Quaadgras e8fdfeb72b reflect: add iterator equivalents for NumField, NumIn, NumOut and NumMethod
The new methods are Type.Fields, Type.Methods, Type.Ins, Type.Outs,
Value.Fields and Value.Methods.

These methods have been introduced into the reflect package (as well
as tests) replacing three-clause for loops where possible.

Fixes #66631

Change-Id: Iab346e52c0eadd7817afae96d9ef73a35db65fd2
GitHub-Last-Rev: 8768ef71b9
GitHub-Pull-Request: golang/go#75646
Reviewed-on: https://go-review.googlesource.com/c/go/+/707356
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-11-25 09:18:42 -08:00

345 B

[reflect.Type] includes new methods that return iterators for a type's fields, methods, inputs and outputs. Similarly, [reflect.Value] includes two new methods that return iterators over a value's fields or methods, each element being a pair of the value ([reflect.Value]) and its type information ([reflect.StructField] or [reflect.Method]).