]> Cypherpunks repositories - gostls13.git/commitdiff
go/parser: deprecate parser.ParseDir
authorqiulaidongfeng <2645477756@qq.com>
Thu, 13 Feb 2025 17:07:54 +0000 (01:07 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 19 Feb 2025 19:49:13 +0000 (11:49 -0800)
Fixes #71122

Change-Id: Icaf27842f4a42e11eea4bd2203eba5d56610c196
Reviewed-on: https://go-review.googlesource.com/c/go/+/649275
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

api/next/71122.txt [new file with mode: 0644]
doc/next/6-stdlib/99-minor/go/parser/71122.md [new file with mode: 0644]
src/go/parser/interface.go

diff --git a/api/next/71122.txt b/api/next/71122.txt
new file mode 100644 (file)
index 0000000..a679899
--- /dev/null
@@ -0,0 +1 @@
+pkg go/parser, func ParseDir //deprecated #71122
diff --git a/doc/next/6-stdlib/99-minor/go/parser/71122.md b/doc/next/6-stdlib/99-minor/go/parser/71122.md
new file mode 100644 (file)
index 0000000..2043d30
--- /dev/null
@@ -0,0 +1 @@
+The [ParseDir] function is deprecated.
index 71a612f7cf49670c331d5ba0f0e57d7538254746..a9a1cfb736aa9af05866067971429437bddc34eb 100644 (file)
@@ -145,6 +145,11 @@ func ParseFile(fset *token.FileSet, filename string, src any, mode Mode) (f *ast
 // If the directory couldn't be read, a nil map and the respective error are
 // returned. If a parse error occurred, a non-nil but incomplete map and the
 // first error encountered are returned.
+//
+// Deprecated: ParseDir does not consider build tags when associating
+// files with packages. For precise information about the relationship
+// between packages and files, use golang.org/x/tools/go/packages,
+// which can also optionally parse and type-check the files too.
 func ParseDir(fset *token.FileSet, path string, filter func(fs.FileInfo) bool, mode Mode) (pkgs map[string]*ast.Package, first error) {
        list, err := os.ReadDir(path)
        if err != nil {