Movatterモバイル変換


[0]ホーム

URL:


importer

packagestandard library
go1.25.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:8Imported by:2,172

Details

Repository

cs.opensource.google/go/go

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

func Default()types.Importer

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

func For(compilerstring, lookupLookup)types.Importer

For callsForCompiler with a new FileSet.

Deprecated: UseForCompiler, which populates a FileSetwith the positions of objects created by the importer.

funcForCompileradded ingo1.12

func ForCompiler(fset *token.FileSet, compilerstring, lookupLookup)types.Importer

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.

Types

typeLookup

type Lookup func(pathstring) (io.ReadCloser,error)

A Lookup function returns a reader to access package data fora given import path, or an error if no matching package is found.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp