Movatterモバイル変換


[0]ホーム

URL:


srcimporter

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:13Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package srcimporter implements importing directlyfrom source files rather than installed packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeImporter

type Importer struct {// contains filtered or unexported fields}

An Importer provides the context for importing packages from source code.

funcNew

func New(ctxt *build.Context, fset *token.FileSet, packages map[string]*types.Package) *Importer

New returns a new Importer for the given context, file set, and mapof packages. The context is used to resolve import paths to package paths,and identifying the files belonging to the package. If the context providesnon-nil file system functions, they are used instead of the regular packageos functions. The file set is used to track position information of packagefiles; and imported packages are added to the packages map.

func (*Importer)Import

func (p *Importer) Import(pathstring) (*types.Package,error)

Import(path) is a shortcut for ImportFrom(path, ".", 0).

func (*Importer)ImportFrom

func (p *Importer) ImportFrom(path, srcDirstring, modetypes.ImportMode) (*types.Package,error)

ImportFrom imports the package with the given import path resolved from the given srcDir,adds the new package to the set of packages maintained by the importer, and returns thepackage. Package path resolution and file system operations are controlled by the contextmaintained with the importer. The import mode must be zero but is otherwise ignored.Packages that are not comprised entirely of pure Go files may fail to import because thetype checker may not be able to determine all exported entities (e.g. due to cgo dependencies).

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