find

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package find implements search funcs for finding files by name or content

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func By

func By(m Matcher, root string) (result *list.List, err error)

By returns a list of files whose names match

func ByName

func ByName(pattern, root string) (result *list.List, err error)

ByName returns a list of files whose names match the shell like pattern

Example
os.Chdir(testRoot)
result, _ := ByName("*.txt", ".")
for e := result.Front(); e != nil; e = e.Next() {
	if s, ok := e.Value.(string); ok {
		fmt.Println(s)
	}
}
Output:

a.txt
b.txt

func InFile

func InFile(pattern, file string) (result *list.List, err error)

InFile opens and the file and uses InStream to find references

func InStream

func InStream(pattern string, stream io.Reader) *list.List

InStream works much like grep, finding references by the given pattern

Types

type Matcher

type Matcher interface {
	Match(path string) bool
}

func NewRegexp

func NewRegexp(ex *regexp.Regexp) Matcher

func NewShellPattern

func NewShellPattern(pattern string) Matcher

type Ref

type Ref struct {
	LineNo int
	Line   string
}

Ref points to a line in a file starting from 0

func (*Ref) String

func (ref *Ref) String() string

Jump to

Keyboard shortcuts

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