Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/knsh14/astree
- Owner: knsh14
- License: mit
- Created: 2019-08-02T09:00:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-30T04:13:40.000Z (over 2 years ago)
- Last Synced: 2024-10-28T13:11:25.117Z (23 days ago)
- Topics: abstract-syntax-tree, ast, go, tree-command
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 mainimport (
"go/parser"
"go/token"
"log"
"os""github.com/knsh14/astree"
)func main() {
code := `
package mainimport (
"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)
}
```