Documentation
¶
Index ¶
- Variables
- func AddImportDecl(file *ast.File, imports []string)
- func Export(targets Targets, outfilename, outpackage, outvarname string) (*ast.File, error)
- func GetImportDecl(p *ast.File) *ast.GenDecl
- func GetProgram(pkgs []string) (*loader.Program, error)
- func GetVarDecl(p *ast.File, name string) *ast.GenDecl
- func InjectAliasedImportPaths(importPath string, alias string, decl *ast.GenDecl)
- func InjectImportPaths(importPaths []string, decl *ast.GenDecl)
- func MustGetImportDecl(p *ast.File) *ast.GenDecl
- func NewImportDecl() *ast.GenDecl
- func NewImportSpec(importPath string, importName string) *ast.ImportSpec
- func NewPkg(fileName string, pkgName string) (*ast.Package, *ast.File)
- func PrintAstFile(w io.Writer, node interface{}) error
- func PublicIdents(targetPackagePaths Targets, outvarname string, prog *loader.Program, ...) (ast.Decl, error)
- func Symbolic(targetPackagePaths Targets, outvarname string, prog *loader.Program, ...) (*ast.GenDecl, []string, error)
- type Target
- type Targets
Constants ¶
This section is empty.
Variables ¶
var EnableCache = true
EnableCache set cache status
Functions ¶
func AddImportDecl ¶
AddImportDecl creates and add an import statement to the file.
func GetImportDecl ¶
GetImportDecl returns the ast node of the import declaration.
func GetProgram ¶
GetProgram creates a new Program of a list of packages.
func GetVarDecl ¶
GetVarDecl returns the ast node of the variable declaration.
func InjectAliasedImportPaths ¶
InjectAliasedImportPaths injects given import path into the provided decl.
func InjectImportPaths ¶
InjectImportPaths injects given import paths into the provided decl.
func MustGetImportDecl ¶
MustGetImportDecl returns the ast node of the import declaration.
func NewImportDecl ¶
NewImportDecl creates a new import(...) declaration
func NewImportSpec ¶
func NewImportSpec(importPath string, importName string) *ast.ImportSpec
NewImportSpec creates a new import statement
func PrintAstFile ¶
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",
},
}