Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Criteria ¶
type Criteria struct {
// contains filtered or unexported fields
}
func NewCriteria ¶
func NewCriteria(args ...CriteriaArg) (Criteria, error)
NewCriteria build search Criteria for analyse
type CriteriaArg ¶
type CriteriaArg = func(*Criteria)
func WithAnalyseScope ¶
func WithAnalyseScope(scope string) CriteriaArg
WithAnalyseScope set full abs path to some project directory can be project root, or some child directory, like 'internal' only this directory and it`s child will be analysed for params
func WithExcludedFileMatchers ¶
func WithExcludedFileMatchers(matchers []*regexp.Regexp) CriteriaArg
WithExcludedFileMatchers define list of regexp matchers that will match each file name in analyse scope if regexp match file name, it will be analysed for params
func WithExcludedPath ¶
func WithExcludedPath(paths []string) CriteriaArg
WithExcludedPath define list of abs path directories for exclude from analyse scope
func WithPackagePath ¶
func WithPackagePath(path string) CriteriaArg
WithPackagePath set full abs path to go package who will be analysed
type Gate ¶
type Gate struct { MethodName string // function name (func Hello(a,b int), name="Hello") ParamName string // function param name (func (_a_,b int), name="a") Index int // function param index (func (a,b bool, c int), for c index=2) MethodDefinition Source // where method is defined ArgumentDefinition Source // where method param type defined (func (a,b,c _int_)) Interface Interface // used interface for injection Implementations []Implementation // all code links to this param IsVariadic bool // function param is variadic (func (a bool, nums ...int)) }
type Implementation ¶
type InjectionMethod ¶
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
func NewSearcher ¶
func NewSearcher() *Searcher
func (*Searcher) Usages ¶
func (s *Searcher) Usages(c Criteria) ([]InjectionMethod, error)
Usages share same packages cache for every function call so it`s good idea to check every package in project with same Searcher instance
This method will find all package functions with interfaces and link it to all callers, with implementations it will skip:
- methods without interface (not injectable)
- private methods (nobody outside can call it)
- only write chan (func (ch chan<-) (our code send something, so we not depend on implementations)
- with placeholder param names (func (_ myInterface)), nobody can use _, so code not depend on interface
Can`t search from multiple goroutines, but safe for concurrent use (mutex inside)