importer

package
v0.0.0-...-ff11b4d Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package importer provides implementation of go/type/importer.

It provides an ability to collect information, such as types, definitions, usages about the package and all inner packages.

The main method is Collect. It will analyze package and return pointer to package and file set. Also, CollectInfoImporter.Info structure will bee filled. For example,

info := types.Info{
	Types: make(map[ast.Expr]types.TypeAndValue),
	Defs:  make(map[*ast.Ident]types.Object),
	Uses:  make(map[*ast.Ident]types.Object),
}
importer := new(CollectInfoImporter)
importer.Pkg = pkg + "/testfunc/main"
importer.Info = &info
resultPkg, fset, err := importer.Collect()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectInfoImporter

type CollectInfoImporter struct {
	//Info struct that will be filled by Collect() method
	Info *types.Info
	//Package that should be a start point to collect info
	Pkg string
	// contains filtered or unexported fields
}

CollectInfoImporter importing packages with dependencies and collecting information to info field. You need to provide Pkg and Info prior to use it

func (*CollectInfoImporter) Collect

func (_importer *CollectInfoImporter) Collect() (*types.Package, *token.FileSet, error)

Collect going through package and collect info using conf.Check method. It's using this implementation of importer for check all inner packages and go/types/importer.Default() to check all built in packages (without sources)

func (*CollectInfoImporter) Import

func (_importer *CollectInfoImporter) Import(path string) (*types.Package, error)

Import parses the package or returns it from cache if it was already imported. Also, it collects information if path is under Pkg package

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL