Documentation
¶
Overview ¶
Package injector provides a facility to inject code into go programs, either in source (intended to be checked in by the user) or at compilation time (via `-toolexec`).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InjectedFile ¶
type InjectedFile struct {
// References holds new references created while injecting the package, if any.
References typed.ReferenceMap
// Filename is the name of the file that needs to be compiled in place of the original one. It may be identical to
// the input file if the Injector.ModifiedFile function is nil or returns identity.
Filename string
}
InjectedFile contains information about a modified file. It can be used to update compilation instructions.
type Injector ¶
type Injector struct {
// ImportPath is the import path of the package that will be injected.
ImportPath string
// Name is the name of the package that will be injected. If blank, it will be determined from parsing source files.
Name string
// GoVersion is the go runtime version required by this package. If blank, no go runtime compatibility will be
// asserted.
GoVersion string
// TestMain must be set to true when injecting into the generated test main package.
TestMain bool
// ImportMap is a map of import paths to their respective .a archive file. Without transitive dependencies
ImportMap map[string]string
// ModifiedFile is called to determine the output file name for a modified file. If nil, the input file is modified
// in-place.
ModifiedFile func(string) string
// Lookup is a function that resolves and imported package's archive file.
Lookup importer.Lookup
// RootConfig is the root configuration value to use.
RootConfig map[string]string
// contains filtered or unexported fields
}
Injector injects go code into a specific Go package.
func (*Injector) InjectFiles ¶
func (i *Injector) InjectFiles(ctx gocontext.Context, files []string, aspects []*aspect.Aspect) (_ map[string]InjectedFile, _ context.GoLangVersion, err error)
InjectFiles performs injections on the specified files. All provided file paths must belong to the import path set on the receiving Injector. The method returns a map that associates the original source file path to the modified file information. It does not contain entries for unmodified files.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
advice
Package advice provides implementations of the injector.Action interface for common AST changes.
|
Package advice provides implementations of the injector.Action interface for common AST changes. |
|
advice/code/generator
command
|
|
|
join
Package join provides implementations of the InjectionPoint interface for common injection points.
|
Package join provides implementations of the InjectionPoint interface for common injection points. |
|
Package config contains APIs used to work with injector configuration files, which are formed by FilenameOrchestrionToolGo and FilenameOrchestrionYML files.
|
Package config contains APIs used to work with injector configuration files, which are formed by FilenameOrchestrionToolGo and FilenameOrchestrionYML files. |
Click to show internal directories.
Click to hide internal directories.