github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types2/package.go (about)

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types2
     6  
     7  // A Package describes a Go package.
     8  type Package struct {
     9  	path      string
    10  	name      string
    11  	scope     *Scope
    12  	imports   []*Package
    13  	complete  bool
    14  	fake      bool
    15  	cgo       bool
    16  	goVersion string
    17  }
    18  
    19  // NewPackage returns a new Package for the given package path and name.
    20  // The package is not complete and contains no explicit imports.
    21  func NewPackage(path, name string) *Package
    22  
    23  // Path returns the package path.
    24  func (pkg *Package) Path() string
    25  
    26  // Name returns the package name.
    27  func (pkg *Package) Name() string
    28  
    29  // SetName sets the package name.
    30  func (pkg *Package) SetName(name string)
    31  
    32  // GoVersion returns the minimum Go version required by this package.
    33  // If the minimum version is unknown, GoVersion returns the empty string.
    34  // Individual source files may specify a different minimum Go version,
    35  // as reported in the [go/ast.File.GoVersion] field.
    36  func (pkg *Package) GoVersion() string
    37  
    38  // Scope returns the (complete or incomplete) package scope
    39  // holding the objects declared at package level (TypeNames,
    40  // Consts, Vars, and Funcs).
    41  // For a nil pkg receiver, Scope returns the Universe scope.
    42  func (pkg *Package) Scope() *Scope
    43  
    44  // A package is complete if its scope contains (at least) all
    45  // exported objects; otherwise it is incomplete.
    46  func (pkg *Package) Complete() bool
    47  
    48  // MarkComplete marks a package as complete.
    49  func (pkg *Package) MarkComplete()
    50  
    51  // Imports returns the list of packages directly imported by
    52  // pkg; the list is in source order.
    53  //
    54  // If pkg was loaded from export data, Imports includes packages that
    55  // provide package-level objects referenced by pkg. This may be more or
    56  // less than the set of packages directly imported by pkg's source code.
    57  //
    58  // If pkg uses cgo and the FakeImportC configuration option
    59  // was enabled, the imports list may contain a fake "C" package.
    60  func (pkg *Package) Imports() []*Package
    61  
    62  // SetImports sets the list of explicitly imported packages to list.
    63  // It is the caller's responsibility to make sure list elements are unique.
    64  func (pkg *Package) SetImports(list []*Package)
    65  
    66  func (pkg *Package) String() string