Home

Awesome

Goblin

Build Status codecov.io

goblin is an executable that uses Go's ast, parser, and token modules to dump a Go expression, statement, or file to JSON. It is small, fast, self-contained, and incurs no dependencies.

Usage

goblin --file [FILENAME] dumps a given file. goblin --expr EXPR dumps an expression. goblin --stmt STMT dumps a statement—due to a quirk in the Go AST API, this statement will be surrounded by a dummy function.

Format

Every node is a JSON object containing at least two guaranteed keys:

I apologize for the semantic overlap associated with the vagueness of the words "kind" and "type". Suggestions as to better nomenclature are welcomed.

FAQ's

Why not use the ast.Visitor interface instead of recursing manually into every node? Because Visitor is inherently side-effectual: it declares no return type, so it is not possible to use it to express an algebra (which is all this program really is).

Licensing

goblin is open-source software © Reconfigure.io, released to the public under the terms of the Apache 2.0 license. A copy can be found under the LICENSE file in the project root.

Contributing

Pull requests are enthusiastically accepted!

By participating in this project you agree to follow the Contributor Code of Conduct.

TODO

Known Issues