search

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

* Glimpse - Index Module * Author: Pratyush Yadav <pratyushyadav0106@gmail.com> * Description: In-memory indexing system for fast code search * License: MIT License

* Glimpse - Search Engine Module * Author: Pratyush Yadav <pratyushyadav0106@gmail.com> * Description: Core search functionality with file traversal and pattern matching * License: MIT License

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBinaryFile

func IsBinaryFile(filename string) bool

Types

type FileEntry

type FileEntry struct {
	Path    string    // File path
	Content []string  // File lines (original)
	Lower   []string  // File lines (lowercase for fast case-insensitive search)
	ModTime time.Time // Last modification time
}

FileEntry represents a single indexed file with its content

type Index

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

Index represents an in-memory index of files in a directory

func BuildIndex

func BuildIndex(dir string, progressCallback func(current, total int)) *Index

BuildIndex creates an index of all text files in the given directory progressCallback is called with current and total during indexing

func (*Index) FileCount

func (idx *Index) FileCount() int

FileCount returns the number of indexed files

func (*Index) GetFileContent

func (idx *Index) GetFileContent(filename string) []string

returns the cached content lines for a file Returns nil if file not found in index

func (*Index) Search

func (idx *Index) Search(pattern string, options SearchOptions) []Result

Search searches the index for a pattern and returns matching results

type Result

type Result struct {
	File    string
	Line    int
	Content string
}

func SearchFiles

func SearchFiles(pattern string, dir string, options SearchOptions) []Result

type SearchOptions

type SearchOptions struct {
	CaseInsensitive bool
	MaxResults      int
}

Jump to

Keyboard shortcuts

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