https://github.com/pytimer/astutil
Go ast util
https://github.com/pytimer/astutil
Last synced: 5 months ago
JSON representation
Go ast util
- Host: GitHub
- URL: https://github.com/pytimer/astutil
- Owner: pytimer
- License: apache-2.0
- Created: 2021-09-08T02:36:58.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-10T10:06:00.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T15:48:03.453Z (almost 2 years ago)
- Language: Go
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
}
}
}
```