pkg flag, func BoolFunc(string, string, func(string) error) #53747
pkg flag, method (*FlagSet) BoolFunc(string, string, func(string) error) #53747
pkg go/ast, func IsGenerated(*File) bool #28089
+pkg go/ast, func NewPackage //deprecated #52463
pkg go/ast, type File struct, GoVersion string #59033
+pkg go/ast, type Importer //deprecated #52463
+pkg go/ast, type Object //deprecated #52463
+pkg go/ast, type Package //deprecated #52463
+pkg go/ast, type Scope //deprecated #52463
pkg go/build/constraint, func GoVersion(Expr) string #59033
pkg go/build, type Directive struct #56986
pkg go/build, type Directive struct, Pos token.Position #56986
Ident struct {
NamePos token.Pos // identifier position
Name string // identifier name
- Obj *Object // denoted object; or nil
+ Obj *Object // denoted object, or nil. Deprecated: see Object.
}
// An Ellipsis node stands for the "..." type in a
Decls []Decl // top-level declarations; or nil
FileStart, FileEnd token.Pos // start and end of entire file
- Scope *Scope // package scope (this file only)
+ Scope *Scope // package scope (this file only). Deprecated: see Object
Imports []*ImportSpec // imports in this file
- Unresolved []*Ident // unresolved identifiers in this file
+ Unresolved []*Ident // unresolved identifiers in this file. Deprecated: see Object
Comments []*CommentGroup // list of all comments in the source file
GoVersion string // minimum Go version required by //go:build or // +build directives
}
// A Package node represents a set of source files
// collectively building a Go package.
+//
+// Deprecated: use the type checker [go/types] instead; see [Object].
type Package struct {
Name string // package name
Scope *Scope // package scope across all files
// Importer should load the package data for the given path into
// a new *Object (pkg), record pkg in the imports map, and then
// return pkg.
+//
+// Deprecated: use the type checker [go/types] instead; see [Object].
type Importer func(imports map[string]*Object, path string) (pkg *Object, err error)
// NewPackage creates a new Package node from a set of File nodes. It resolves
// belong to different packages, one package name is selected and files with
// different package names are reported and then ignored.
// The result is a package node and a scanner.ErrorList if there were errors.
+//
+// Deprecated: use the type checker [go/types] instead; see [Object].
func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer, universe *Scope) (*Package, error) {
var p pkgBuilder
p.fset = fset
// A Scope maintains the set of named language entities declared
// in the scope and a link to the immediately surrounding (outer)
// scope.
+//
+// Deprecated: use the type checker [go/types] instead; see [Object].
type Scope struct {
Outer *Scope
Objects map[string]*Object
// Kind Data type Data value
// Pkg *Scope package scope
// Con int iota for the respective declaration
+//
+// Deprecated: The relationship between Idents and Objects cannot be
+// correctly computed without type information. For example, the
+// expression T{K: 0} may denote a struct, map, slice, or array
+// literal, depending on the type of T. If T is a struct, then K
+// refers to a field of T, whereas for the other types it refers to a
+// value in the environment.
+//
+// New programs should set the [parser.SkipObjectResolution] parser
+// flag to disable syntactic object resolution (which also saves CPU
+// and memory), and instead use the type checker [go/types] if object
+// resolution is desired. See the Defs, Uses, and Implicits fields of
+// the [types.Info] struct for details.
type Object struct {
Kind ObjKind
Name string // declared name
Trace // print a trace of parsed productions
DeclarationErrors // report declaration errors
SpuriousErrors // same as AllErrors, for backward-compatibility
- SkipObjectResolution // don't resolve identifiers to objects - see ParseFile
+ SkipObjectResolution // skip deprecated identifier resolution; see ParseFile
AllErrors = SpuriousErrors // report all errors (not just the first 10 on different lines)
)
// for the src parameter must be string, []byte, or io.Reader.
// If src == nil, ParseFile parses the file specified by filename.
//
-// The mode parameter controls the amount of source text parsed and other
-// optional parser functionality. If the SkipObjectResolution mode bit is set,
-// the object resolution phase of parsing will be skipped, causing File.Scope,
-// File.Unresolved, and all Ident.Obj fields to be nil.
+// The mode parameter controls the amount of source text parsed and
+// other optional parser functionality. If the SkipObjectResolution
+// mode bit is set (recommended), the object resolution phase of
+// parsing will be skipped, causing File.Scope, File.Unresolved, and
+// all Ident.Obj fields to be nil. Those fields are deprecated; see
+// [ast.Object] for details.
//
// Position information is recorded in the file set fset, which must not be
// nil.