sourcecode

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*sourceCodeHandlerImpl)

func WithAssetPath

func WithAssetPath(assetsPath string) Option

func WithSkipDirs

func WithSkipDirs(dirs ...string) Option

// WithEntrySignature 定义服务调用函数签名, 方便定位哪个文件需要patch来添加模块所在包的导入路径

func WithParseSignature(signature string) Option {
	return func(m *sourceCodeHandlerImpl) error {
		if signature == "" {
			return errors.New("patch file signature not specified")
		}

		tokens := strings.Split(signature, ".")
		if len(tokens) != 2 {
			return errors.New("invalid signature format, format: caller.functionChain")
		}

		importPath, functionChain := strings.TrimSpace(tokens[0]), strings.TrimSpace(tokens[1])
		if importPath == "" || functionChain == "" {
			return errors.New("empty import path or function chain")
		}

		m.signature = &callSignature{
			caller: importPath,
			functionChain: functionChain,
		}
		return nil
	}
}

type Parser

type Parser interface {
	Parse() (*sourceCodeInfo, error)
}

type SourceCodeHandler

type SourceCodeHandler interface {
	Handle() error
}

func New

func New(srcDir string, options ...Option) SourceCodeHandler

New 初始化源代码管理器

Jump to

Keyboard shortcuts

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