gorep is a high-performance command-line tool for searching files, built with Go. It aims to provide a fast and efficient alternative to traditional tools like grep and ripgrep, with a focus on concurrent file processing and user-friendly output.
- Concurrent Search: Utilizes Go's goroutines for parallel file processing with a worker pool model.
- Colored Output: Highlights matches and file paths for better readability (can be disabled with
--no-color). - Context Lines: Supports showing lines before (
-B), after (-A), or around (-C) matches, with deduplicated context blocks similar toripgrep. - Binary File Detection: Automatically skips binary files using extension-based filtering and null byte detection.
- Glob Filtering: Include or exclude files based on glob patterns (
--includeand--exclude). - Gitignore Support: Respects
.gitignorerules by default (can be disabled with--no-gitignore). - Fixed String and Regex Modes: Search with literal strings (
-F) or regular expressions.
go install github.com/yourusername/gorep@latest(Replace yourusername with your GitHub username once uploaded.)
Once releases are available on GitHub, you can download pre-built binaries from the releases page.
# Basic search
gorep "pattern" /path/to/search
# Fixed string search (literal match)
gorep -F "function name" .
# Case-insensitive search
gorep -i "function" .
# Show 2 lines of context before and after matches
gorep -C 2 "function" .
# Include only specific file types
gorep --include "*.go" --include "*.py" "function" .
# Exclude certain directories or file types
gorep --exclude "vendor/*" --exclude "*.log" "function" .
# Ignore .gitignore rules
gorep --no-gitignore "function" .
# Disable colored output
gorep --no-color "function" .Benchmark results on a directory with ~21,667 files (/home/123kaze/Project/claude-code-source-code-main):
| Case | rg median | grep median | gorep median | Conclusion |
|---|---|---|---|---|
Fixed String: function |
0.0436s | 0.3404s | 0.1957s | rg fastest |
Fixed String: TODO |
0.0314s | 0.2400s | 0.1461s | rg fastest |
| Fixed String: No match | 0.0324s | 0.2426s | 0.1387s | rg fastest |
| Regex: `function | class | const` | 0.0509s | 0.4846s |
| Regex: `(function | class | const)\s+Identifier` | 0.0781s | 0.7447s |
Fixed String + TS/TSX only: import |
0.0249s | 0.9552s | 0.1339s | rg fastest |
Key Takeaways:
gorepoutperformsgrepin fixed-string searches.gorep's regex performance needs optimization compared torgand sometimesgrep.- Full report: benchmark_report.md
git clone https://github.com/yourusername/gorep.git
cd gorep
go build .- Concurrent file walking and searching
- Colored terminal output with match highlighting
- Context line display (
-B,-A,-C) - Binary file detection and skipping
- Glob pattern include/exclude
-
.gitignoresupport - Search statistics (
--stats) - JSON output format (
--json) - Performance optimizations (buffer tuning, byte-level matching)
- Benchmark comparisons with
grep/ripgrep
This project is licensed under the MIT License - see the LICENSE file for details.