gogrep

package
v0.0.0-...-7fc3621 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileMatches

type FileMatches struct {
	Path    string
	Matches []Match
	Count   int // total match count in this file
}

FileMatches groups all matches within a single file.

type GrepOptions

type GrepOptions struct {
	Pattern          string
	Path             string
	Type             string // file type filter: "go", "js", "py", etc.
	Glob             string // glob pattern filter: "*.tsx", "src/**/*.go"
	OutputMode       string // "content" (default), "files_with_matches", "count"
	CaseInsensitive  bool
	Context          int // lines of context around match (-C)
	After            int // lines after match (-A)
	Before           int // lines before match (-B)
	LineNumbers      bool
	HeadLimit        int // limit output entries
	Offset           int // skip first N entries
	Multiline        bool
	RespectGitignore *bool // nil = auto (true if in git repo), true/false = explicit
}

GrepOptions configures a grep operation.

type Match

type Match struct {
	Path       string   // file path (relative to search root)
	LineNumber int      // 1-based line number of the match
	Column     int      // 0-based byte offset within the line
	Line       string   // the matched line content (without trailing newline)
	Before     []string // context lines before the match
	After      []string // context lines after the match
}

Match represents a single match within a file.

type Results

type Results struct {
	Files      []FileMatches // one entry per file with matches
	TotalCount int           // total matches across all files
	Truncated  bool          // true if HeadLimit caused early termination
}

Results holds the complete output of a grep operation.

func Grep

func Grep(ctx context.Context, opts GrepOptions) (*Results, error)

Grep performs a grep operation and returns structured results.

Directories

Path Synopsis
internal
gitignore
Package gitignore implements .gitignore pattern matching for directory walking.
Package gitignore implements .gitignore pattern matching for directory walking.

Jump to

Keyboard shortcuts

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