The test logs show the following error
row 0 - got data of type graph.Node but wanted graph.Node
--- FAIL: TestAlls (0.84s)
panic: interface conversion: interface {} is graph.Node, not graph.Node [recovered]
panic: interface conversion: interface {} is graph.Node, not graph.Node
From the following code
nnn = graph.Node{}
nnn, ok = row[0].(graph.Node)
if !ok {
log.Printf("row 0 - got data of type %T but wanted graph.Node", nnn)
}
neo4jNode := row[0].(graph.Node)
I am using glide install, go clean, go build, go test.
Is it possible that there are two different types with the same name? (graph.Node)
Yes. If the code that produces the object (whatever is generating rows
) references a different copy of the same library , the types will not match - for example, if you reference library foo
, which has graph
vendored, it will be referencing its vendored version, while you are referencing your own version. It's also possible to have two completely different packages (different import paths) both named graph
but I'm assuming you've ruled this out.
In which case, which folders should I clear out?
It's unfortunately not that simple - you need to look carefully at your dependencies. If you're importing a project as a library, and it has its own dependencies vendored, you're going to have a bad time. That's exactly why it's a bad practice to vendor dependencies in a library (dependencies should only be vendored for binaries).
What does [recovered] mean?
It means a panic
was recovered . This is done by the testing library to return accurate test results in the event of a test causing a panic.
The origin of the problem was multiple glide.yaml (& vendor/) in the repository. The solution was to only have a root glide.yaml (& vendor/).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.