gogrep

command module
v0.0.0-...-79713fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

README

gogrep

Rog and Dan's drunken idea. Work in progress.

go get -u mvdan.cc/gogrep

Its first argument is a pattern to match. It can be any Go expression or statement, which may include wildcards. Wildcards are identifiers preceded by $.

$ gogrep 'if $x != nil { return $x }'
main.go:47:2: if err != nil { return err; }
main.go:60:2: if err != nil { return err; }

All wildcards with the same name must match the same syntax node. In other words, they must be equal in the source code. The $_ wildcard doesn't follow this rule, so it can be used to match anything regardless of how often it is used.

You can also use a * wildcard suffix to match any number of expressions or statements, such as:

$ gogrep 'if err != nil { $_* }'
main.go:47:2: if err != nil { return err; }
main.go:60:2: if err != nil { return err; }
tokenize.go:42:3: if err != nil { return nil, err; }

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL