gogrep
gogrep copied to clipboard
Search for Go code using syntax trees
This project was fun and interesting, but I haven't put a significant amount of work into it for over a year. The project aimed to solve two main use cases,...
This brings README.md and the usage printed by the command into sync, and also adds information about available attributes. I've reverse-engineered the descriptions from my idea of what the code...
I think the documentation could be slightly improved with gogrep-related materials, like https://github.com/mvdan/talks/blob/master/2018/gogrep.slide It gives a pretty good introduction for people who are new to a concept of ast-based code...
How about having a `-d` (or -v) argument to print the AST type information of the matched node and the `$x` patterns? Currently, when a pattern match occurs, gogrep prints...
In writing linters (in my case, `go/analysis` passes to be run as golangci-lint plugins) I find myself wanting some sort of AST-matching engine. This tool seems like a really great...
Suppose you're about to do some refactoring inside some specific file. You want to do a `-x pattern` with `-s replacement` to get the job done. The problem is that...
Prior to commit 58f4747 (port to go/packages), it was possible to run gogrep on a file that doesn't pass type checking. But that no longer works. It would be nice...
Simple queries can be done as a pipeline, such as finding all unnecessary uses of `[:]` on strings: $ gogrep -x '$x[:]' -a 'type(string)' However, this quickly breaks down if...
It seems that `$*_` can't be used inside import spec: ```go import ($*_; "something/of/interest"; $*_) ``` The parsing error is: ``` cannot parse expr: 1:1: expected statement, found 'import' ```...
Right now we only have `$*` to match optional parts. Sometimes we want to match exactly 1 optional node inside a pattern. It's either nil or it matches exactly 1...