Documentation ¶
Overview ¶
Package check
I. Go Files & Packages ¶
1. Get current go.mod & module name
2. List all files with their path & corresponding package
3. For each file call AST to get list of files where DI pkg is imported & For each file with di pkg imported:
3.a. List all Container & Get/Must...-function declaration
3.b. In each file of the pkg: recursively try to find any usage of "locally" declared Container & Func Ident
4. List Container & ValueFunc Ident in all files of this go module/repo
5. asda
Improvements: ¶
Create a build function for any Container that is created. That means any created Container (even private ones) can be built (`Container.Build()`)from outside the package.
Maybe: recursively parse all go modules used in the GOPATH to check graph, e.g. to check if there is any circular dependencies, or in any other cases where user just want to check all dependencies.
II. AST ¶
1. visit AST to get a list of go file where the DI package called + have the ident used in that file 2. List declaration of Container (var/const/:=...) 3. List declaration of Get/Must/MustWithOptions/Set...-functions 4. List Container Ident usage 5. List Get/Must...-functions Ident usage/calls 6. Make a list of all usages of di.Values[T] and recursively there usages... (have a Max Depth option) 7. Make a graph between declaration and usages
III. Graph ¶
1. Create a Graph from the list of all vertices (usages of Ident) & Nodes (declaration)
2. Check if Graph is a DAG (has any circular dependencies)package check
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DIRelationshipGraph ¶ added in v0.0.3
func DIRelationshipGraph()
DIRelationshipGraph traverses a given function to find any reference to a DI ValueFunc, di.Container or to a DI Value. We will also track Ident which have a di ValueFunc, di.Container or di.Value
func FuncRelationshipGraph ¶ added in v0.0.3
FuncRelationshipGraph traverses a given function and finds statement and expressions that refers to other function calls in order to produce a slice of nodes and vertices.
Each function is a node & each function call in a func is one of its vertices. Vertices are ordered, by order of apparition in the func's body.
Usage:
We will traverse that tree/graph to find if a di.Value was used before being Set, etc...
func LocalPackages ¶ added in v0.0.3
LocalPackages returns a slice of available pkg definitions from the given []*loader.Package
Usage:
These LocalPackages are used when recursively traversing the tree of the given function (e.g. a main func) to know if a package is locally defined, and therefore subject to be traversed.
If we encounter a function call with a local package ref, we will traverse that function and recursively perform the same operations on its sequence of statement. This operation will build a func relationship graph.
Types ¶
This section is empty.