filesearch

package
v0.4.135 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 6 Imported by: ? 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

Overview

Package filesearch finds files and folders by name under some folders, for the search of Files (CasaOS#184). It reads names only, never contents, does not follow links (a link is matched by its own name and not walked into), and stops at a number of hits, a number of entries read or a deadline, whichever comes first, saying so.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = Limits{Hits: 200, Entries: 200_000, Time: 8 * time.Second}

DefaultLimits is what a search of Files is held to: enough for a person to read, and light enough for a small box.

Functions

This section is empty.

Types

type Hit

type Hit struct {
	Name  string
	Path  string
	IsDir bool
	Size  int64
	Date  time.Time
}

Hit is a file or folder whose name holds the query.

type Limits

type Limits struct {
	Hits    int           // hits returned at most
	Entries int           // entries read at most
	Time    time.Duration // how long the walk may take
}

Limits bound one search.

type Result

type Result struct {
	Hits      []Hit
	Truncated bool
}

Result is the hits, in the order the walk met them, and whether a limit stopped it before every folder was read.

func Search(ctx context.Context, starts []string, query string, limits Limits) Result

Search walks each folder of starts and returns the entries whose name holds query, case not minded. A folder it cannot read is skipped. ctx ends it early too.

Jump to

Keyboard shortcuts

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