MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / main

Function main

example/dep/main.go:8–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6)
7
8func main() {
9
10 // A->C->B
11 // A->B
12 A := &model.DepGraph{Name: "A"}
13 B := &model.DepGraph{Name: "B"}
14 C := &model.DepGraph{Name: "C"}
15 A.AppendChild(C)
16 A.AppendChild(B)
17 C.AppendChild(B)
18
19 logs.Info("foreach node")
20 A.ForEachNode(func(p, n *model.DepGraph) bool {
21 if p != nil {
22 logs.Infof("%s->%s", p.Name, n.Name)
23 }
24 return true
25 })
26
27 logs.Info("foreach path")
28 A.ForEachPath(func(p, n *model.DepGraph) bool {
29 if p != nil {
30 logs.Infof("%s->%s", p.Name, n.Name)
31 }
32 return true
33 })
34
35 logs.Infof("dep tree foreach path, sorted by addition:\n%s", A.Tree(true, false))
36 logs.Infof("dep tree foreach node, sorted by addition:\n%s", A.Tree(false, false))
37 logs.Infof("dep tree foreach path, sorted by name:\n%s", A.Tree(true, true))
38 logs.Infof("dep tree foreach node, sorted by name:\n%s", A.Tree(false, true))
39
40 A.Build(false, model.Lan_Java)
41 logs.Infof("build by bfs, foreach path:\n%s", A.Tree(true, false))
42 logs.Infof("build by bfs, foreach node:\n%s", A.Tree(false, false))
43
44 // clear path
45 A.ForEachNode(func(p, n *model.DepGraph) bool { n.Language = model.Lan_None; n.Path = ""; return true })
46
47 A.Build(true, model.Lan_Golang)
48 logs.Infof("build by dfs, foreach path:\n%s", A.Tree(true, false))
49 logs.Infof("build by dfs, foreach node:\n%s", A.Tree(false, false))
50
51}

Callers

nothing calls this directly

Calls 7

AppendChildMethod · 0.95
ForEachNodeMethod · 0.95
ForEachPathMethod · 0.95
TreeMethod · 0.95
BuildMethod · 0.95
InfoFunction · 0.92
InfofFunction · 0.92

Tested by

no test coverage detected