Open vonhraban opened 4 years ago
@vonhraban - could you try sth. like:
for it.Next() {
node, ok := it.Node().(nodes.Object)
if !ok {
continue
}
fmt.Println(node["Name"])
}
Btw. if you just need to extract imports then I highly recommend to use https://github.com/src-d/imports project instead. It's based on tree-sitter so it's much faster and does not require any server.
The example in the docs provides a code snippet to extract the imports from the file. However marshalling nodes into JSON is not a good use case, and I am trying to find a way to get the name of the import without intermediate marhsaling.
It is in the node under Path/Name, but how do I access it?
Also while testing it locally with a Go file the following was the output
Somehow Path/Name became Path/Names.
I can not find docs anywhere about how to read data from nodes.