search

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

func ErrorMessage

func ErrorMessage(err error) string

func IsContextError

func IsContextError(err error) bool

func IsResourceLimit

func IsResourceLimit(err error) bool

Types

type Config

type Config struct {
	Mode         Mode
	MaxResults   int
	Workers      int
	Globs        []string
	RequestLimit int
}

type Emitter

type Emitter func(Event) error

type Error

type Error struct {
	Code string
	Err  error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Event

type Event struct {
	Type          string               `json:"type"`
	SchemaVersion int                  `json:"schema_version,omitempty"`
	Provider      string               `json:"provider,omitempty"`
	Repository    string               `json:"repository,omitempty"`
	RequestedRef  string               `json:"requested_ref,omitempty"`
	ResolvedRef   string               `json:"resolved_ref,omitempty"`
	Commit        string               `json:"commit,omitempty"`
	CommitInfo    *provider.CommitInfo `json:"commit_info,omitempty"`
	Mode          Mode                 `json:"mode,omitempty"`
	Path          string               `json:"path,omitempty"`
	Line          int                  `json:"line,omitempty"`
	Column        int                  `json:"column,omitempty"`
	Text          string               `json:"text,omitempty"`
	Context       string               `json:"context,omitempty"`
	Submatches    []Submatch           `json:"submatches,omitempty"`
	Code          string               `json:"code,omitempty"`
	Message       string               `json:"message,omitempty"`
	Summary       *Summary             `json:"summary,omitempty"`
}

func NewMetaEvent

func NewMetaEvent(snapshot provider.Snapshot, mode Mode, includeCommitInfo bool) Event

func NewSummaryEvent

func NewSummaryEvent(summary Summary) Event

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

type FileResult

type FileResult struct {
	Events   []Event
	Matches  int
	HitLimit bool
}

type GlobSet

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

func CompileGlobs

func CompileGlobs(patterns []string) (*GlobSet, error)

func (*GlobSet) Match

func (g *GlobSet) Match(filePath string) bool

type Matcher

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

func NewMatcher

func NewMatcher(config MatcherConfig) (*Matcher, error)

func (*Matcher) LiteralPrefix

func (m *Matcher) LiteralPrefix() string

func (*Matcher) Scan

func (m *Matcher) Scan(filePath string, reader io.Reader, maxMatches int) (FileResult, error)

func (*Matcher) ScanEmit

func (m *Matcher) ScanEmit(filePath string, reader io.Reader, maxMatches int, emit func(Event) error) (FileResult, error)

func (*Matcher) ScanEmitContext

func (m *Matcher) ScanEmitContext(ctx context.Context, filePath string, reader io.Reader, maxMatches int, emit func(Event) error) (FileResult, error)

type MatcherConfig

type MatcherConfig struct {
	Pattern    string
	Fixed      bool
	IgnoreCase bool
	Word       bool
	Before     int
	After      int
}

type Mode

type Mode string
const (
	ModeAuto    Mode = "auto"
	ModeExact   Mode = "exact"
	ModeIndexed Mode = "indexed"
)

type Runner

type Runner struct {
	Provider provider.Provider
	Cache    *cache.Cache
	Matcher  *Matcher
	Config   Config
}

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, snapshot provider.Snapshot, emit Emitter) (Summary, error)

type Submatch

type Submatch struct {
	Start int    `json:"start"`
	End   int    `json:"end"`
	Text  string `json:"text"`
}

type Summary

type Summary struct {
	MatchedLines    int                 `json:"matched_lines"`
	MatchedFiles    int                 `json:"matched_files"`
	ScannedFiles    int                 `json:"scanned_files"`
	CacheHits       int                 `json:"cache_hits"`
	DownloadedBytes int64               `json:"downloaded_bytes"`
	SkippedBinary   int                 `json:"skipped_binary"`
	APIRequests     int                 `json:"api_requests"`
	APIRetries      int                 `json:"api_retries"`
	RequestLimit    int                 `json:"request_limit"`
	RateLimit       *provider.RateLimit `json:"rate_limit,omitempty"`
	Transport       string              `json:"transport,omitempty"`
	Complete        bool                `json:"complete"`
	Truncated       bool                `json:"truncated"`
	Reason          string              `json:"reason,omitempty"`
	DurationMS      int64               `json:"duration_ms"`
}

Jump to

Keyboard shortcuts

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