Documentation ¶
Index ¶
- func AddImport(fs *token.FileSet, ast *ast.File, name string, path string) error
- func DumpAstFile(fset *token.FileSet, astFile *ast.File, dstFile string) error
- func Run(iCtx *InstContext, r *PassRegistry, passNames []string) error
- func RunPass(p InstPass, iCtx *InstContext) error
- type InstContext
- type InstPass
- type InstPassConstructor
- type NoPassError
- type PassExistedError
- type PassRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpAstFile ¶
DumpAstFile serialized AST to given file
func Run ¶
func Run(iCtx *InstContext, r *PassRegistry, passNames []string) error
Run executes passes with given a list of pass name and instrumentation context.
func RunPass ¶
func RunPass(p InstPass, iCtx *InstContext) error
Types ¶
type InstContext ¶
type InstContext struct { File string OriginalContent []byte FS *token.FileSet AstFile *ast.File Type *types.Info Metadata map[string]interface{} // user can set custom metadata come along with instrumentation context }
InstContext contains all information needed to instrument one single Golang source code.
func NewInstContext ¶
func NewInstContext(goSrcFile string) (*InstContext, error)
NewInstContext creates a InstContext by given Golang source file
func (*InstContext) GetMetadata ¶
func (i *InstContext) GetMetadata(key string) (interface{}, bool)
func (*InstContext) SetMetadata ¶
func (i *InstContext) SetMetadata(key string, value interface{})
type InstPass ¶
type InstPass interface { // Deps returns a list of dependent passes Deps() []string Before(iCtx *InstContext) GetPreApply(iCtx *InstContext) func(*astutil.Cursor) bool GetPostApply(iCtx *InstContext) func(*astutil.Cursor) bool After(iCtx *InstContext) }
InstPass shapes the pass used for instrumenting a single Golang source code
type InstPassConstructor ¶
type InstPassConstructor func() InstPass
type NoPassError ¶
type NoPassError struct {
Name string
}
func (*NoPassError) Error ¶
func (e *NoPassError) Error() string
type PassExistedError ¶
type PassExistedError struct {
Name string
}
func (*PassExistedError) Error ¶
func (e *PassExistedError) Error() string
type PassRegistry ¶
type PassRegistry struct {
// contains filtered or unexported fields
}
PassRegistry records all registered passes
func NewPassRegistry ¶
func NewPassRegistry() *PassRegistry
func (*PassRegistry) GetNewPassInstance ¶
func (r *PassRegistry) GetNewPassInstance(name string) (InstPass, error)
GetPass returns the pass with given name
func (*PassRegistry) HasPass ¶
func (r *PassRegistry) HasPass(name string) bool
HasPass return true if pass registered, false otherwise
func (*PassRegistry) ListOfPassNames ¶
func (r *PassRegistry) ListOfPassNames() []string
func (*PassRegistry) Register ¶
func (r *PassRegistry) Register(name string, passc InstPassConstructor) error
AddPass adds a unique pass into registry
Click to show internal directories.
Click to hide internal directories.