search

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(filename string, find []byte, ignoreCase bool) (int, []textpos.Match)

File looks for a literal string (no regexp) within a file, in given case-sensitive way, returning number of occurrences and specific match position list. Column positions are in runes.

func FileRegexp

func FileRegexp(filename string, re *regexp.Regexp) (int, []textpos.Match)

FileRegexp looks for a string using Go regexp expression within a file, returning number of occurrences and specific match position list. Column positions are in runes.

func LangCheck

func LangCheck(fi *fileinfo.FileInfo, langs []fileinfo.Known) bool

LangCheck checks if file matches list of target languages: true if matches (or no langs)

func LexItems

func LexItems(src [][]rune, lexs []lexer.Line, find []byte, ignoreCase bool) (int, []textpos.Match)

LexItems looks for a string (no regexp), as entire lexically tagged items, with given case-sensitivity returning number of occurrences and specific match position list. Column positions are in runes.

func Reader

func Reader(reader io.Reader, find []byte, ignoreCase bool) (int, []textpos.Match)

Reader looks for a literal string (no regexp) from an io.Reader input stream, using given case-sensitivity. Returns number of occurrences and specific match position list. Column positions are in runes.

func ReaderRegexp

func ReaderRegexp(reader io.Reader, re *regexp.Regexp) (int, []textpos.Match)

ReaderRegexp looks for a string using Go regexp expression, from an io.Reader input stream. Returns number of occurrences and specific match position list. Column positions are in runes.

func RuneLines

func RuneLines(src [][]rune, find []byte, ignoreCase bool) (int, []textpos.Match)

RuneLines looks for a string (no regexp) within lines of runes, with given case-sensitivity returning number of occurrences and specific match position list. Column positions are in runes.

func RuneLinesRegexp

func RuneLinesRegexp(src [][]rune, re *regexp.Regexp) (int, []textpos.Match)

RuneLinesRegexp looks for a regexp within lines of runes, with given case-sensitivity returning number of occurrences and specific match position list. Column positions are in runes.

Types

type Results

type Results struct {
	Filepath string
	Count    int
	Matches  []textpos.Match
}

Results is used to report search results.

func All

func All(root string, find string, ignoreCase, regExp bool, langs []fileinfo.Known, exclude ...string) ([]Results, error)

All returns list of all files under given root path, in all subdirs, of given language(s) that contain the given string, sorted in descending order by number of occurrences.

  • ignoreCase transforms everything into lowercase.
  • regExp uses the go regexp syntax for the find string.
  • exclude is a list of filenames to exclude.

func Paths

func Paths(paths []string, find string, ignoreCase, regExp bool, langs []fileinfo.Known, exclude ...string) ([]Results, error)

Paths returns list of all files in given list of paths (only: no subdirs), of language(s) that contain the given string, sorted in descending order by number of occurrences. Paths can be relative to current working directory. Automatically skips generated files.

  • ignoreCase transforms everything into lowercase.
  • regExp uses the go regexp syntax for the find string.
  • exclude is a list of filenames to exclude: can use standard Glob patterns.

func (*Results) String

func (r *Results) String() string

Jump to

Keyboard shortcuts

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