https://github.com/knsh14/astree
tree command for Go AST
https://github.com/knsh14/astree
abstract-syntax-tree ast go tree-command
Last synced: 2 months 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-30T04:13:40.000Z (almost 3 years ago)
- Last Synced: 2025-04-18T15:16:45.397Z (3 months ago)
- Topics: abstract-syntax-tree, ast, go, tree-command
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 13
- Watchers: 1
- 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)
}
```