injector

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

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 {
	// Aspects is the set of configured aspects to use.
	Aspects []*aspect.Aspect

	// 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

	// 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(files []string) (map[string]InjectedFile, context.GoLangVersion, 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.

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.
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 builtin contains built-in injection configurations for supported instrumentations.
Package builtin contains built-in injection configurations for supported instrumentations.
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.

Jump to

Keyboard shortcuts

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