iperf3exporter/vendor/github.com/go-toolsmith/astp
Marvin Preuss 2343c9588a
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
first commit
2021-10-20 10:08:56 +02:00
..
.gitignore first commit 2021-10-20 10:08:56 +02:00
.travis.yml first commit 2021-10-20 10:08:56 +02:00
decl.go first commit 2021-10-20 10:08:56 +02:00
expr.go first commit 2021-10-20 10:08:56 +02:00
LICENSE first commit 2021-10-20 10:08:56 +02:00
README.md first commit 2021-10-20 10:08:56 +02:00
stmt.go first commit 2021-10-20 10:08:56 +02:00

Go Report Card GoDoc Build Status

astp

Package astp provides AST predicates.

Installation:

go get github.com/go-toolsmith/astp

Example

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")
	}
}