analyzer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Analyze

func Analyze(ctx context.Context, fset *token.FileSet, files []*ast.File, runFuncName string, initializerFuncNameOption string, targetPackageID string, moduleRootPath string, loader *loader.Loader) (*metadata.CommandMetadata, string, error)

Analyze inspects the AST of Go files to extract command metadata. - fset: Token FileSet. - files: ASTs of the files to analyze (typically from the target package). - runFuncName: Name of the main run function. - targetPackageID: Import path of the package containing the runFuncName (e.g., "testmodule/example.com/mainpkg"). - moduleRootPath: Absolute path to the root of the module this package belongs to. - loader: Loader for lazy loading of package information. - initializerFuncNameOption: User-specified name for the options initializer function.

func AnalyzeOptions

func AnalyzeOptions(
	ctx context.Context,
	fset *token.FileSet,
	optionsTypeName string,
	targetPackagePath string,
	baseDir string,
	loader *loader.Loader,
) ([]*metadata.OptionMetadata, string, error)

AnalyzeOptions finds the Options struct definition using the lazyload package. It performs type analysis for interface checking and resolving embedded structs.

  • fset: Token fileset for parsing.
  • optionsTypeName: Name of the options struct type (e.g., "MainConfig").
  • targetPackagePath: The import path of the package containing optionsTypeName.

It performs type analysis for interface checking and resolving embedded structs.

  • fset: Token fileset for parsing.
  • optionsTypeName: Name of the options struct type (e.g., "MainConfig").
  • targetPackagePath: The import path of the package containing optionsTypeName.
  • baseDir: The base directory from which to resolve targetPackagePath (often module root).
  • loader: Instance of loader.Loader.

func AnalyzeRunFunc

func AnalyzeRunFunc(files []*ast.File, funcName string) (*metadata.RunFuncInfo, string, error)

AnalyzeRunFunc finds the specified 'run' function in the AST and extracts its metadata. It returns the RunFuncInfo, the function's doc comment, and any error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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