Skip to content
vennictusPublic

About

a cli search tool built in go that's fast af.

Resources

Stars

10 stars

Watchers

0 watching

Forks

Repository files navigation

  ____  ___  ____  _____    _    ____   ____ _   _ 
 / ___|/ _ \/ ___|| ____|  / \  |  _ \ / ___| | | |
| |  _| | | \___ \|  _|   / _ \ | |_) | |   | |_| |
| |_| | |_| |___) | |___ / ___ \|  _ <| |___|  _  |
 \____|\___/|____/|_____/_/   \_\_| \_\\____|_| |_|

A blazing-fast, concurrent code search tool built in Go

CI Go Report Card Go Version License: MIT

Search codebases in milliseconds | Respects .gitignore | Zero dependencies


Installation | Quick Start | Features | Documentation

Features

Performance

  • Concurrent pipeline — 4-stage parallel processing
  • Dynamic worker scaling — adapts to workload
  • Memory efficient — streams results, doesn't buffer

Search Capabilities

  • Substring & regex — flexible pattern matching
  • Case-insensitive — optional -i flag
  • Whole-word — boundary-aware with -w

Smart Filtering

  • Gitignore support — respects .gitignore rules
  • Custom ignores — .gosearchignore files
  • Extension filter — search only .go, .ts, etc.

Developer Experience

  • JSON output — pipe to jq, integrate with tools
  • Shell completions — bash, zsh, fish
  • Exit codes — scriptable 0/1/2 semantics

Installation

# Install directly with Go (recommended)
go install github.com/vennictus/gosearch@latest

# Or clone and build
git clone https://github.com/vennictus/gosearch.git
cd gosearch && go build -o gosearch .

Requirements: Go 1.21 or higher


Quick Start

# Search for "TODO" in current directory
gosearch "TODO" .

# Case-insensitive search
gosearch -i "error" ./src

# Find function definitions with regex
gosearch -regex "func\s+\w+\(" .

# Search only Go files
gosearch -extensions .go "panic" .

# Get JSON output for tooling
gosearch -format json "config" . | jq '.matches'

# Just count matches
gosearch -count "FIXME" .

Command Reference

Category Flag Description Example
Search Mode -i Case-insensitive matching gosearch -i "Error" .
-w Match whole words only gosearch -w "log" .
-regex Treat pattern as regex gosearch -regex "v[0-9]+" .
Filtering -extensions Only search these extensions -extensions .go,.ts
-exclude-dir Skip directories by name -exclude-dir vendor,node_modules
-max-size Skip files larger than size -max-size 1MB
-max-depth Limit directory depth -max-depth 3
Output -format Output format (plain/json) -format json
-color Highlight matches -color
-count Only print match count -count
-quiet No output, exit code only -quiet
Performance -workers Number of search workers -workers 8
-dynamic-workers Auto-scale worker count -dynamic-workers
-metrics Show performance stats -metrics

Exit Codes

Code Meaning Use Case
0 Matches found Success — pattern was found
1 No matches Pattern not found (not an error)
2 Error Invalid args, bad regex, etc.

Perfect for scripting:

if gosearch -quiet "TODO" .; then
    echo "Found TODOs!"
fi

Performance

gosearch uses a 4-stage concurrent pipeline:

┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│  Traversal  │───>│  IO Workers │───>│ CPU Workers │───>│   Printer   │
│  (walker)   │    │ (file read) │    │  (search)   │    │  (output)   │
└─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘

Benchmarks (searching 10,000 files):

BenchmarkSmallFiles-8       1000    1.2ms/op    0 allocs/op
BenchmarkLargeFiles-8        100   12.4ms/op    0 allocs/op

Configuration

Config File

Create .gosearchrc in your project root:

{
  "ignore_case": true,
  "format": "json",
  "extensions": [".go", ".ts", ".js"],
  "exclude_dirs": ["vendor", "node_modules", ".git"]
}

Ignore Files

Create .gosearchignore (same syntax as .gitignore):

# Skip generated files
*.generated.go
*_gen.go

# Skip test fixtures
testdata/
fixtures/

Shell Completions

# Bash
gosearch -completion bash > ~/.local/share/bash-completion/completions/gosearch

# Zsh  
gosearch -completion zsh > ~/.zfunc/_gosearch

# Fish
gosearch -completion fish > ~/.config/fish/completions/gosearch.fish

# PowerShell
gosearch -completion powershell >> $PROFILE

Project Structure

gosearch/
├── main.go                 # Entry point & pipeline orchestration
├── internal/
│   ├── config/             # CLI parsing, validation, config loading
│   ├── search/             # Matcher, workers, file traversal
│   ├── ignore/             # .gitignore & .gosearchignore parsing
│   └── output/             # Result formatting (plain, JSON, color)
├── completions/            # Shell completion scripts
├── testdata/               # Test fixtures (unicode, edge cases, code samples)
└── scripts/                # Build & release automation

Documentation

Document Description
GUIDE.md Deep-dive tutorial for beginners — explains every concept from scratch
PRODUCT_SPEC.md Full technical specification and design documentation

Development

# Run all tests
go test ./...

# Run with race detector
go test -race ./...

# Run benchmarks
go test -bench=. -benchmem ./...

# Build for current platform
go build -o gosearch .

License

MIT License — see LICENSE for details.


Built with Go

Back to top

About

a cli search tool built in go that's fast af.

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages