Ruleguard by example: AST filters

package gorules

import "github.com/quasilyte/go-ruleguard/dsl"

func goRecover(m dsl.Matcher) {
	// This `recover()` matching happens on AST (node) level,
	// not on a text level.
	m.Match(`go func () { $*body }`).
		Where(m["body"].Contains(`recover()`)).
		Report("called recover() inside go stmt")
}
package main

import "fmt"

func main() {
	go func() {
		rv := recover()
		panic(rv)
	}
}

Notes: