Add Scope.Objects iterator
Code that walks the objects in a types.Scope usually loops over Scope.Names() and calls Lookup for each name. This pattern appears dozens of times in x/tools alone.
The proposal adds a Scope.Objects method that returns an iterator. It yields the scope's objects in name order.
for obj := range pkg.Scope().Objects() {
fmt.Println(obj.Name(), obj.Type())
}
- Proposal
- #80449 by adonovan
- Status
- Implemented on Sep 21, 2026
- Release
- Go 1.28
- Impact
- low
- Area
- go/types