Skip to content

Commit abd0239

Browse files
qiulaidongfenggopherbot
authored andcommitted
go/parser: deprecate parser.ParseDir
Fixes #71122 Change-Id: Icaf27842f4a42e11eea4bd2203eba5d56610c196 Reviewed-on: https://go-review.googlesource.com/c/go/+/649275 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Commit-Queue: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 3f46587 commit abd0239

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

api/next/71122.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg go/parser, func ParseDir //deprecated #71122
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The [ParseDir] function is deprecated.

src/go/parser/interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ func ParseFile(fset *token.FileSet, filename string, src any, mode Mode) (f *ast
145145
// If the directory couldn't be read, a nil map and the respective error are
146146
// returned. If a parse error occurred, a non-nil but incomplete map and the
147147
// first error encountered are returned.
148+
//
149+
// Deprecated: ParseDir does not consider build tags when associating
150+
// files with packages. For precise information about the relationship
151+
// between packages and files, use golang.org/x/tools/go/packages,
152+
// which can also optionally parse and type-check the files too.
148153
func ParseDir(fset *token.FileSet, path string, filter func(fs.FileInfo) bool, mode Mode) (pkgs map[string]*ast.Package, first error) {
149154
list, err := os.ReadDir(path)
150155
if err != nil {

0 commit comments

Comments
 (0)