- Dev:
Run
sh dev.sh
- Builds project to exe (on Windows) in build folder
- Runs executable with some test arguments
- Prod:
Run
sh prod.sh
- Builds project to exe (on Windows) in build folder
- Add Environment Variable to gogrep build folder (or move exe/binary to appropriate folder)
gogrep [OPTIONS] PATTERN [FILE/DIRECTORY]
- Options
-r
: read all files under each directory recursively
- Start gogrep, pass in parameters:
- target string/regex
- root directory (implicit or explicit)
- ignores
- Recursively read contents of root directory
- If item is a directory:
- Append name to current root
- Recurse search function with new root directory in a new goroutine
- If item is a file:
- Read contents line by line and search/match with target string/regex
- Output a match
- If item is a directory:
- Matching data to target
- Good old fashion, line by line reading and matching string
- Using Boyer-Moore algorithm (same one used by GNU grep)
- For regexes, using Go's built-in methods (since they're quite fast)
- GoGrep with Boyer-Moore can only handle ASCII characters (need to deal with "weird" files like .exe, .db, etc.)
- Only looks for string patterns (no regex yet)
- I was bored
- Learned Go last Sunday, wanted to test my knowledge out