loader

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoadMode

type LoadMode int

LoadMode determines how a path should be loaded

const (
	// PackageLoadMode indicates that the path is an import path and should be loaded with that context
	PackageLoadMode LoadMode = iota
	// FileLoadMode indicates that the path points to a file (relative or absolute)
	FileLoadMode
)

func (LoadMode) String

func (l LoadMode) String() string

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader is a utility service for extracting type information from a go package

func DefaultLoader

func DefaultLoader() *Loader

DefaultLoader creates the default loader

func NewLoader

func NewLoader(pkgLoader func(cfg *packages.Config, patterns ...string) ([]*packages.Package, error)) *Loader

NewLoader creates a loader with the package loader override given in the ctor, this is to aid in testing

func (*Loader) LoadAll

func (l *Loader) LoadAll(path string, mode LoadMode) (map[string]*Result, error)

LoadAll loads all types discovered in the path that are interface types

func (*Loader) LoadMatched

func (l *Loader) LoadMatched(path string, expressions []string, mode LoadMode) (map[string]*Result, error)

LoadMatched loads types that match the given expressions, the expressions can be regex or strings to be exact-matched

func (*Loader) LoadOne

func (l *Loader) LoadOne(path, name string, mode LoadMode) (*Result, error)

LoadOne loads the given type

type LoadingError

type LoadingError struct {
	Errors []error
}

LoadingError holds any errors that occurred while loading a package

func (*LoadingError) Error

func (l *LoadingError) Error() string

type Result

type Result struct {
	Name       string
	TypeParams []jen.Code
	TypeArgs   []jen.Code
	Methods    []*method.Method
}

Result holds the results of loading a particular type

Jump to

Keyboard shortcuts

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