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

https://github.com/pytimer/astutil

Go ast util
https://github.com/pytimer/astutil

Last synced: 5 months ago
JSON representation

Go ast util

Awesome Lists containing this project

README

          

# astutil

Go ast util generate AST by parsing all go file of the project

## Usage

```go
package main

import (
goparser "go/parser"
"log"

"github.com/pytimer/astutil"
)

func main() {
pkgs := astutil.ParseDir("./testdata", []string{"vendor"}, goparser.ParseComments)
for k, pkg := range pkgs {
log.Printf("package path: %s, name: %s\n", k, pkg.Name)
for _, f := range pkg.Files {
log.Printf("astFile path: %s package: %s\n", f.Path, f.PackagePath)
// log.Println(f.File)
log.Printf("comments: %#v", f.Comments)
}
}
}
```