Skip to content

Commit 8043c80

Browse files
committed
Few fixes
1 parent 45aae67 commit 8043c80

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

cmd/graph-db/main.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,36 @@
11
package main
22

33
import (
4+
"graph-db/api"
5+
"graph-db/internal/app/core/structs"
46
"graph-db/internal/app/core"
57
"graph-db/internal/pkg/utils"
68
"graph-db/internal/app/core/globals"
79
"log"
8-
"graph-db/api"
9-
"graph-db/internal/app/core/structs"
1010
)
1111

1212
func printNode(node structs.Node) {
1313
var str string
1414
str += "Node labels: "
1515
for _, label := range node.GetLabel().GetLabelNames() {
16-
if label.GetTitle() != "" {
16+
if label != nil && label.GetTitle() != "" {
1717
str += label.GetTitle()
1818
str += ", "
1919
}
2020
}
2121
str += "\n"
2222
str += "Relationships: \n"
2323
relationship := node.GetRelationship()
24-
i := 1
25-
for true {
26-
if relationship != nil {
27-
str += "\n\t"
28-
str += string(i)
29-
str += "\t Title: "
30-
str += relationship.GetTitle().GetTitle()
31-
i++
32-
}
24+
if relationship != nil {
25+
str += "\t Title: "
26+
str += relationship.GetTitle().GetTitle()
3327
}
28+
println(str)
3429
}
3530

3631
func main() {
3732
//err := core.InitDb("asd", "local")
38-
//err = core.SwitchDb("asd")
33+
////err = core.SwitchDb("asd")
3934
//utils.CheckError(err)
4035

4136
dbTitle := "asd"
@@ -52,11 +47,11 @@ func main() {
5247
newBs := make([]byte, 4)
5348
dfh.Read(globals.NodesStore, 20, &newBs, 0)
5449

55-
//if string(newBs) != string(bs) {
56-
// log.Fatal("Byte arrays are not the same!")
57-
//} else {
58-
// println("Congratulations!")
59-
//}
50+
if string(newBs) != string(bs) {
51+
log.Fatal("Byte arrays are not the same!")
52+
} else {
53+
println("Congratulations!")
54+
}
6055

6156
node1 := api.CreateNode("Kevin")
6257
node2 := api.CreateNode("Sergey")

0 commit comments

Comments
 (0)