Background: it is common when working with the go/ast package to need to enumerate the list of parameter or result variables declared by a function.
Proposal: We propose to add a Variables method to ast.FieldList that returns an iterator over the sequence of variables, as defined below.
package ast // go/ast
// Variables returns an iterator over each variable declared by a FieldList.
// Each variable is represented by a (name, field) pair, where name provides
// the name (if any), and the field provides the type and position.
func (list *FieldList) Variables() iter.Seq2[*Ident, *Field]
For implementation, see astutil.FlatFields in x/tools.
Background: it is common when working with the
go/astpackage to need to enumerate the list of parameter or result variables declared by a function.Proposal: We propose to add a Variables method to ast.FieldList that returns an iterator over the sequence of variables, as defined below.
For implementation, see astutil.FlatFields in x/tools.