ripgrep

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAvailable = errors.New("ripgrep: rg binary not available")

ErrNotAvailable is returned when the ripgrep binary cannot be found or executed.

Functions

This section is empty.

Types

type ExecFunc

type ExecFunc func(ctx context.Context, name string, args []string, dir string) (stdout []byte, exitCode int, err error)

ExecFunc executes a binary by name with args in dir and returns its stdout, exit code, and any execution error.

type GlobOptions

type GlobOptions struct {
	IncludeHidden bool
	Ignore        []string
}

GlobOptions configures file matching options for [Glob].

type Match

type Match struct {
	Path    string `json:"path"`
	Line    int    `json:"line"`
	Column  int    `json:"column"`
	Content string `json:"content"`
}

Match represents a text match returned by [Search].

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner executes ripgrep commands through an injected ExecFunc (such as a sandbox Proc capability) and caches binary availability per Runner instance.

func New

func New(execFn ExecFunc) *Runner

New creates a new ripgrep Runner backed by execFn.

func (*Runner) Glob

func (r *Runner) Glob(ctx context.Context, searchPath, pattern string, opts ...GlobOptions) ([]string, error)

Glob searches for files matching pattern under searchPath using ripgrep.

func (*Runner) IsAvailable

func (r *Runner) IsAvailable(ctx context.Context) bool

IsAvailable reports whether the ripgrep (rg) binary is available via Runner's ExecFunc. If rg was not found previously, it re-checks at most once every 30 seconds.

func (*Runner) Search

func (r *Runner) Search(ctx context.Context, searchPath, pattern string, opts ...SearchOptions) ([]Match, error)

Search searches for pattern in text files under searchPath using ripgrep.

type SearchOptions

type SearchOptions struct {
	Literal         bool
	Include         string
	CaseInsensitive bool
	IncludeHidden   bool
}

SearchOptions configures pattern search options for [Search].

Jump to

Keyboard shortcuts

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