https://github.com/go-toolsmith/astp
Package astp provides AST predicates.
https://github.com/go-toolsmith/astp
ast go golang predicates
Last synced: 5 months ago
JSON representation
Package astp provides AST predicates.
- Host: GitHub
- URL: https://github.com/go-toolsmith/astp
- Owner: go-toolsmith
- License: mit
- Created: 2018-06-12T16:17:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-11-23T09:01:45.000Z (7 months ago)
- Last Synced: 2025-12-08T01:08:54.515Z (7 months ago)
- Topics: ast, go, golang, predicates
- Language: Go
- Size: 21.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# astp
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![version-img]][version-url]
Package `astp` provides AST predicates.
## Installation:
Go version 1.16+
```bash
go get github.com/go-toolsmith/astp
```
## Example
```go
package main
import (
"fmt"
"github.com/go-toolsmith/astp"
"github.com/go-toolsmith/strparse"
)
func main() {
if astp.IsIdent(strparse.Expr(`x`)) {
fmt.Println("ident")
}
if astp.IsBlockStmt(strparse.Stmt(`{f()}`)) {
fmt.Println("block stmt")
}
if astp.IsGenDecl(strparse.Decl(`var x int = 10`)) {
fmt.Println("gen decl")
}
}
```
## License
[MIT License](LICENSE).
[build-img]: https://github.com/go-toolsmith/astp/workflows/build/badge.svg
[build-url]: https://github.com/go-toolsmith/astp/actions
[pkg-img]: https://pkg.go.dev/badge/go-toolsmith/astp
[pkg-url]: https://pkg.go.dev/github.com/go-toolsmith/astp
[reportcard-img]: https://goreportcard.com/badge/go-toolsmith/astp
[reportcard-url]: https://goreportcard.com/report/go-toolsmith/astp
[version-img]: https://img.shields.io/github/v/release/go-toolsmith/astp
[version-url]: https://github.com/go-toolsmith/astp/releases