Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/knsh14/astree

tree command for Go AST
https://github.com/knsh14/astree

abstract-syntax-tree ast go tree-command

Last synced: 12 days ago
JSON representation

tree command for Go AST

Awesome Lists containing this project

README

        

astree
---

tree command for Go AST

# install
```
go get -u github.com/knsh14/astree/cmd/astree
```

# options

# Example
https://play.golang.org/p/up3cRnFCm61

```
package main

import (
"go/parser"
"go/token"
"log"
"os"

"github.com/knsh14/astree"
)

func main() {
code := `
package main

import (
"fmt"
)

func main() {
fmt.Println("Hello, playground")
}`
fs := token.NewFileSet()
f, err := parser.ParseFile(fs, "main.go", code, 0)
if err != nil {
log.Fatal(err)
}
astree.File(os.Stdout, fs, f)
}
```