Radar · Go · Archive · Week 22 · May 26 – Jun 1, 2025
go/ast: deprecate FilterPackage, PackageExports, MergePackageFiles
Breakingstdlib
- What changed
- All functions that operate on the deprecated
ast.Packagetype (FilterPackage,PackageExports,MergePackageFiles) and the relatedMergeModetype are now deprecated. - Production impact
- The source does not say.
- Try it
- Refactor any AST‑processing code that relies on
ast.Packageto use the newer*ast.File‑based helpers instead. - Source
- github.com/golang/go/issues/73088
Understand it, then run it
The Go standard library has a package called go/ast that represents Go source code as a tree of nodes. In older versions of the library, a type named ast.Package was used to hold a whole Go package, and several helper functions – FilterPackage, PackageExports, and MergePackageFiles – operated on that type. Those functions are now marked as deprecated, meaning they are still available but are discouraged from use because the type they rely on, ast.Package, is itself deprecated. The change does not add new features; it simply signals that developers should use newer alternatives that work with individual ast.File objects instead.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed