importer
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package importer provides access to export data importers.
These functions, which are mostly deprecated, date from before theintroduction of modules in release Go 1.11. They should no longerbe relied on except for use in test cases using small programs thatdepend only on the standard library. For reliable module-awareloading of type information, use the packages.Load function fromgolang.org/x/tools/go/packages.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcDefault¶
Default returns an Importer for the compiler that built the running binary.If available, the result implementstypes.ImporterFrom.
Default may be convenient for use in the simplest of cases, butmost clients should instead useForCompiler, which accepts atoken.FileSet from the caller; without it, all positioninformation derived from the Importer will be incorrect andmisleading. See also the package documentation.
funcFordeprecated
For callsForCompiler with a new FileSet.
Deprecated: UseForCompiler, which populates a FileSetwith the positions of objects created by the importer.
funcForCompiler¶added ingo1.12
ForCompiler returns an Importer for importing from installed packagesfor the compilers "gc" and "gccgo", or for importing directlyfrom the source if the compiler argument is "source". In thislatter case, importing may fail under circumstances where theexported API is not entirely defined in pure Go source code(if the package API depends on cgo-defined entities, the typechecker won't have access to those).
The lookup function is called each time the resulting importer needsto resolve an import path. In this mode the importer can only beinvoked with canonical import paths (not relative or absolute ones);it is assumed that the translation to canonical import paths is beingdone by the client of the importer.
A lookup function must be provided for correct module-aware operation.Deprecated: If lookup is nil, for backwards-compatibility, the importerwill attempt to resolve imports in the $GOPATH workspace.