lsh

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

This package exposes the functionality of ls-having. For documentation of ls-having, see its home page: https://github.com/handy-common-utils/ls-having

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LsHaving

func LsHaving(options *Options, rootDir string) (found []string, errors []string)

Find directories matching conditions.

The array of paths is returned as the first value, it could be an empty array but would never be nil, and the array is sorted in ascend order. If there is no error, the second value returned would be nil. If there is any error, the array of error messages is returned as the second value.

If the options tells this function to panic on error, the function would return immediately once there's an error. In such case the first returned value could contain some paths, and the second returned value would contain the error message.

If the options tells this function to not panic on error, the function would record the error but continue working in case an error happens. In such case the first returned value would contain all paths found, and the second returned value would contain the error messages.

Types

type Options

type Options struct {
	// Maximum depth to look into subdirectories.
	// The root directory has depth 0.
	// Negative value in this field means no limitation on depth.
	Depth int

	// Directories matching any of these patterns won't be looked into
	Excludes []glob.Glob

	// Exclude root directory in the result to be returned
	ExcludeRoot bool

	// For any (or each, if MatchAllFlagFiles has value true) of these patterns, each of the directories returned must have at least one file matching it.
	FlagFiles []glob.Glob

	// If true then for each of the pattern in FlagFiles, the directory must have at least one file matching.
	// If false then the directory just need to have at least one file matching any pattern in FlagFiles.
	MatchAllFlagFiles bool

	// Additional file that its content would be checked. Use empty string to skip this checking.
	CheckFile string

	// Regular expression used for checking the content of CheckFile
	CheckRegexp *regexp.Regexp

	// Regard not matching as positive when using CheckRegexp to check the content of CheckFile
	CheckInverse bool

	// To return immedately when any error (such like non-existing directory or no access permission) happens
	PanicOnError bool
}

For more details regarding these options, see the home page of ls-having: https://github.com/handy-common-utils/ls-having

Jump to

Keyboard shortcuts

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