Go Git Grep is a small search and replace tool. It works like grep, but is able to replace in files, recursively.
gg '^\s+(.+)\.Log\("level", "(.[^"]+)", ' $GOPATH/src/github.com/dominikschulz/ --exclude vendor/ --workers 20 --replace 'level.${2}(${1}).Log(' --eat-my-data
gg 'level.error\(' $GOPATH/src/github.com/dominikschulz/ --exclude vendor/ --workers 20 --replace 'level.Error(' --eat-my-data --post-proc 'goimports -w'
- Similar tools: grep, ack, the silver searcher, ripgrep
- Should I use this tool? - Probably not. Use ripgrep or your fancy IDE.
- Will this tool destroy my data? - Probably yes. At least if you play around with
--eat-my-data
and--who-needs-backups
- Seriously? Yes. You should know what you do.
- Why did you write it then? Because I wanted recursive search and replace, with git support, on Unix platforms without overloaded IDEs.