export

package
v0.0.0-...-5ea1423 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnableCache = true

EnableCache set cache status

Functions

func AddImportDecl

func AddImportDecl(file *ast.File, imports []string)

AddImportDecl creates and add an import statement to the file.

func Export

func Export(targets Targets, outfilename, outpackage, outvarname string) (*ast.File, error)

Export exports symbolic and public idents information of targets.

func GetImportDecl

func GetImportDecl(p *ast.File) *ast.GenDecl

GetImportDecl returns the ast node of the import declaration.

func GetProgram

func GetProgram(pkgs []string) (*loader.Program, error)

GetProgram creates a new Program of a list of packages.

func GetVarDecl

func GetVarDecl(p *ast.File, name string) *ast.GenDecl

GetVarDecl returns the ast node of the variable declaration.

func InjectAliasedImportPaths

func InjectAliasedImportPaths(importPath string, alias string, decl *ast.GenDecl)

InjectAliasedImportPaths injects given import path into the provided decl.

func InjectImportPaths

func InjectImportPaths(importPaths []string, decl *ast.GenDecl)

InjectImportPaths injects given import paths into the provided decl.

func MustGetImportDecl

func MustGetImportDecl(p *ast.File) *ast.GenDecl

MustGetImportDecl returns the ast node of the import declaration.

func NewImportDecl

func NewImportDecl() *ast.GenDecl

NewImportDecl creates a new import(...) declaration

func NewImportSpec

func NewImportSpec(importPath string, importName string) *ast.ImportSpec

NewImportSpec creates a new import statement

func NewPkg

func NewPkg(fileName string, pkgName string) (*ast.Package, *ast.File)

NewPkg creates a new go package.

func PrintAstFile

func PrintAstFile(w io.Writer, node interface{}) error

PrintAstFile prints an ast to given writer.

func PublicIdents

func PublicIdents(targetPackagePaths Targets, outvarname string, prog *loader.Program, destFile *ast.File) (ast.Decl, error)

PublicIdents exports a map of pkg import path and function ident for every values of the target funcMap defined as an ident or a selector expression. For a funcmap defined such package y

var x := map[string]interface{}{
 "f1": template.HTMLEscaper,
 "f2": PublicFunc,
}

PublicIdents exports their information

var yy = []map[string][string]{
 map[string]string{
  "FuncName": "f1",
  "Sel": "template.HTMLEscaper",
  "Pkg": "html/template",
 },
  "FuncName": "f2",
  "Sel": "y.PublicFunc",
  "Pkg": "some/package/path",
 },
}

func Symbolic

func Symbolic(targetPackagePaths Targets, outvarname string, prog *loader.Program, destFile *ast.File) (*ast.GenDecl, []string, error)

Symbolic a symbolic map of given target package and ther idents.

Types

type Target

type Target struct {
	PkgPath string
	Idents  []string
}

Target defines a target package and idents to export.

type Targets

type Targets []Target

Targets is an alias of []Target

func (*Targets) GetPackagePaths

func (t *Targets) GetPackagePaths() []string

GetPackagePaths returns the list of package path

func (*Targets) Parse

func (t *Targets) Parse(s []string) error

Parse a string of package:var

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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