internal

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package internal contains miscellaneous functions and objects useful within Scalibr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitignoreMatch added in v0.1.8

func GitignoreMatch(gitignores []GitignorePattern, filePath []string, isDir bool) bool

GitignoreMatch returns whether the specified file path should be ignored according to the specified .gitignore patterns.

func MatchNamedCaptureGroups

func MatchNamedCaptureGroups(regEx *regexp.Regexp, content string) map[string]string

MatchNamedCaptureGroups takes a regular expression and string and returns all of the named capture group results in a map. This is only for the first match in the regex. Callers shouldn't be providing regexes with multiple capture groups with the same name.

func ParentDir

func ParentDir(path string, n int) string

ParentDir returns the parent dir up to n dirs deep. If the path is below n dirs, the function returns path. This function assumes no leading `/` or drive letter.

func WalkDirUnsorted

func WalkDirUnsorted(fsys scalibrfs.FS, root string, fn fs.WalkDirFunc, postFN postWalkDirFunc) error

WalkDirUnsorted walks the file tree rooted at root, calling fn for each file or directory in the tree, including root. It also calls postFN after the walk of the file or dir has finished, including the traversal of all sub-directories.

All errors that arise visiting files and directories are filtered by fn: see the fs.WalkDirFunc documentation for details.

WalkDirUnsorted does not follow symbolic links found in directories, but if root itself is a symbolic link, its target will be walked.

Types

type GitignorePattern added in v0.1.8

type GitignorePattern gitignore.Matcher

GitignorePattern is a list of patterns found inside a .gitignore file.

func EmptyGitignore added in v0.2.0

func EmptyGitignore() GitignorePattern

EmptyGitignore returns an empty matcher that doesn't match on any pattern.

func ParseDirForGitignore added in v0.1.8

func ParseDirForGitignore(fs scalibrfs.FS, dirPath string) (GitignorePattern, error)

ParseDirForGitignore parses .gitignore patterns found in the specified directory.

func ParseParentGitignores added in v0.1.8

func ParseParentGitignores(fs scalibrfs.FS, dirPath string) ([]GitignorePattern, error)

ParseParentGitignores parses all .gitignore patterns between the current dir and the scan root, excluding the current directory.

Directories

Path Synopsis
Package units provides constants for common units.
Package units provides constants for common units.

Jump to

Keyboard shortcuts

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