genimport

package
v0.0.0-...-94402ff Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoGenerateMain

func GoGenerateMain(arg []string, imp *Importer) error

GoGenerateMain allows gomacro to be run under go generate. It is used to write new x_package.go import bindings for a package. Thus `go generate` will automatically update your bindings.

To use, add a comment to one go file in your package:

`//go:generate gomacro -g .`

to import the current dir; or one like

`//go:generate gomacro -g github.com/steele232/zoumacro/classic`

to specify the exact import path. The second, specific form, may be necessary if we cannot detect the GOPATH environment variable.

Types

type ImportMode

type ImportMode int
const (
	// ImBuiltin import mechanism is:
	// 1. write a file $GOPATH/src/github.com/steele232/zoumacro/imports/$PKGPATH.go containing a single func init()
	//    i.e. *inside* gomacro sources
	// 2. tell the user to recompile gomacro
	ImBuiltin ImportMode = iota

	// ImThirdParty import mechanism is the same as ImBuiltin, except that files are created in a thirdparty/ subdirectory:
	// 1. write a file $GOPATH/src/github.com/steele232/zoumacro/imports/thirdparty/$PKGPATH.go containing a single func init()
	//    i.e. *inside* gomacro sources
	// 2. tell the user to recompile gomacro
	ImThirdParty

	// ImPlugin import mechanism is:
	// 1. write a file $GOPATH/src/gomacro_imports/$PKGPATH/$PKGNAME.go containing a var Packages map[string]Package
	//    and a single func init() to populate it
	// 2. invoke "go build -buildmode=plugin" on the file to create a shared library
	// 3. load such shared library with plugin.Open().Lookup("Packages")
	ImPlugin

	// ImInception import mechanism is:
	// 1. write a file $GOPATH/src/$PKGPATH/x_package.go containing a single func init()
	//    i.e. *inside* the package to be imported
	// 2. tell the user to recompile $PKGPATH
	ImInception
)

type Importer

type Importer struct {
	PluginOpen r.Value // = reflect.ValueOf(plugin.Open)
	// contains filtered or unexported fields
}

func DefaultImporter

func DefaultImporter(o *Output) *Importer

func (*Importer) Import

func (imp *Importer) Import(path string) (*types.Package, error)

func (*Importer) ImportFrom

func (imp *Importer) ImportFrom(path string, srcDir string, mode types.ImportMode) (*types.Package, error)

func (*Importer) ImportPackage

func (imp *Importer) ImportPackage(name, path string) *PackageRef

func (*Importer) ImportPackageOrError

func (imp *Importer) ImportPackageOrError(name, pkgpath string) (*PackageRef, error)

type Output

type Output = output.Output

type PackageRef

type PackageRef struct {
	imports.Package
	Name, Path string
}

func LookupPackage

func LookupPackage(name, path string) *PackageRef

LookupPackage returns a package if already present in cache

func (*PackageRef) String

func (ref *PackageRef) String() string

type TypeVisitor

type TypeVisitor func(name string, t types.Type) bool

Jump to

Keyboard shortcuts

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