This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · Archive · Week 8 · Feb 17 – 23, 2025

Deprecate parser.ParseDir

Nice to knowtooling

What changed
The Go team marked parser.ParseDir as deprecated. It will still exist and be usable, but it returns ast.Package, which is already deprecated.
Production impact
The source does not say.
Try it
Run go vet on a project that uses parser.ParseDir to see the deprecation warning.
Source
github.com/golang/go/issues/71122

Understand it, then run it

The parser.ParseDir function is a helper that walks a directory and turns every Go file it finds into an abstract syntax tree (AST). The Go team has marked this helper as *deprecated*. That means it still works, but the type it returns, ast.Package, is also deprecated. When you use parser.ParseDir in a new project, your IDE will warn you that the function is old and that you should look for a newer alternative.

The warning does not break your code; it just tells you that the library may remove the function in a future release. The change is part of the normal evolution of the standard library, where older APIs are phased out gradually.

If you are writing a small script or a learning example, you can keep using parser.ParseDir. Just be aware that in the future you might need to switch to a different approach, such as walking the directory yourself and calling parser.ParseFile on each file.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed