Documentation
¶
Index ¶
- Constants
- func AssertDirs(paths ...string)
- func CopyFileOrDir(src string, dest string, existsOk bool) (err error)
- func Exists(path string) (exists bool)
- func ExistsE(path string) (bool, error)
- func ExistsL(path string) (exists bool)
- func ExistsLE(path string) (bool, error)
- func FindFiles(rootDir string, opts ...FindOptions) (files []string, traversedFiles int64, err error)
- func FindFilesByPatterns(rootDir string, includeGlobPatterns []string, excludeGlobPatterns []string, ...) (files []string, traversedFiles int64, err error)
- func FindPaths(rootDir string, opts ...FindOptions) (files []string, traversedFiles int64, err error)
- func IgnoredDirectoriesDefault() []string
- func IsExecutable(path string) bool
- func MakeAbsolute(p string) string
- func MakeAbsoluteTo(base string, p string) string
- func MakeAllAbsolute(p ...string) []string
- func MakeAllAbsoluteTo(base string, p ...string) []string
- func MakeRelativeTo(base string, path string) (s string, e error)
- func MatchByPatterns(s string, includeGlobs, excludeGlobs []string) bool
- func MkDirs(paths ...string) (err error)
- type FindOptions
- func WithPathFilter(f PathFilter, useAnd bool) FindOptions
- func WithPathFilterPatterns(include []string, exclude []string, useAnd bool) FindOptions
- func WithReportOnlyDirs(enable bool) FindOptions
- func WithWalkDirFilter(f PathFilter, useAnd bool) FindOptions
- func WithWalkDirFilterDefault(useAnd bool) FindOptions
- func WithWalkDirFilterPatterns(include []string, exclude []string, useAnd bool) FindOptions
- type PathFilter
Constants ¶
const ( DefaultPermissionsDir = os.FileMode(0775) DefaultPermissionsFile = os.FileMode(0664) StrictPermissionsFile = os.FileMode(0600) )
const ( OutputDir = ".output" // Relative paths to `OutputDir`. OutBuildDir = "build" OutBuildBinDir = "build/bin" OutBuildDocsDir = "build/docs" OutPackageDir = "package" OutCoverageDir = "coverage" OutCoverageDataDir = "coverage/data" OutCoverageBinDir = "coverage/bin" OutImageDir = OutPackageDir DocsDir = "docs" ImagesDir = "images" )
These constants define general directories used throughout the repository.
Variables ¶
This section is empty.
Functions ¶
func AssertDirs ¶
func AssertDirs(paths ...string)
AssertDirs asserts that `path` exists, otherwise panics.
func CopyFileOrDir ¶
CopyFileOrDir copies a directory or file from `src` to `dest`. If `existsOk` is `true` it will replace `dest` if it exists. Copies also symlinks.
func ExistsE ¶
ExistsE checks if a path exists and returns any error associated with `os.Stat`. It follows symlinks.
func ExistsLE ¶
ExistsLE checks if a path exists and returns any error associated with `os.Stat`. It does not follow symlinks.
func FindFiles ¶
func FindFiles( rootDir string, opts ...FindOptions, ) (files []string, traversedFiles int64, err error)
Find all files in `rootDir`. Note: Take care when using WithPathFilter or WithPathFilterPatterns because they will influence how the files are walked. This function uses goroutines under to hood.
func FindFilesByPatterns ¶ added in v0.24.0
func FindFilesByPatterns( rootDir string, includeGlobPatterns []string, excludeGlobPatterns []string, opts ...FindOptions, ) (files []string, traversedFiles int64, err error)
Find all files in `rootDir` which match glob patterns `includePatterns` and not `excludePatterns` (they match the full path). This function uses goroutines under to hood.
func FindPaths ¶ added in v0.24.0
func FindPaths( rootDir string, opts ...FindOptions, ) (files []string, traversedFiles int64, err error)
Find all paths in `rootDir`. Note: Take care when using WithPathFilter or WithPathFilterPatterns because they will influence how the files are walked. This function uses goroutines under to hood.
func IgnoredDirectoriesDefault ¶
func IgnoredDirectoriesDefault() []string
DefaultIgnoredDirectories returns all by default ignored directories.
func IsExecutable ¶
IsExecutable checks if the `path` is executable.
func MakeAbsolute ¶
MakeAbsolute makes path `p` absolute to the current working directory.
func MakeAbsoluteTo ¶
MakeAbsoluteTo makes a path absolute to the `base` directory.
func MakeAllAbsolute ¶
MakeAllAbsolute makes all paths absolute to the current working directory. This function works inplace!
func MakeAllAbsoluteTo ¶
MakeAllAbsoluteTo makes all paths absolute to the `base` directory. This function works inplace!
func MakeRelativeTo ¶ added in v0.26.0
MakeRelativeTo makes a `path` relative to `base`.
func MatchByPatterns ¶
Match a string `name` by some include and exclude glob patterns (doublestar allowed). All errors of `doublestar.ErrBadPattern` will be ignored for performance reason. If `includeGlobs` is empty, it acts as `*` include all.
Types ¶
type FindOptions ¶ added in v0.24.0
type FindOptions func(opts *queryOptions) error
Options to pass to various query function.
func WithPathFilter ¶
func WithPathFilter(f PathFilter, useAnd bool) FindOptions
WithPathFilter set a custom path filter.
func WithPathFilterPatterns ¶ added in v0.26.0
func WithPathFilterPatterns(include []string, exclude []string, useAnd bool) FindOptions
WithPathFilterPatterns sets the doublestar glob patterns path filter on discovered paths.
`useAnd` will logically and this filter to a default one if set.
func WithReportOnlyDirs ¶ added in v0.26.0
func WithReportOnlyDirs(enable bool) FindOptions
WithReportOnlyDirs sets to only walk directories (no files) which means any matching filters are done on directory paths only.
func WithWalkDirFilter ¶ added in v0.26.0
func WithWalkDirFilter(f PathFilter, useAnd bool) FindOptions
WithWalkDirFilter sets a custom walk filter to determine which directories to skip.
func WithWalkDirFilterDefault ¶ added in v0.26.0
func WithWalkDirFilterDefault(useAnd bool) FindOptions
WithWalkDirFilterDefault sets the default walk directory filter if non it set. Note: This is not the same as the `[WithPathFilter]` counter part as it determines the discovery of files when walking the tree. `useAnd` will logically and this filter to a default one if set.
func WithWalkDirFilterPatterns ¶ added in v0.26.0
func WithWalkDirFilterPatterns(include []string, exclude []string, useAnd bool) FindOptions
WithWalkDirFilterPatterns sets doublestar glob patterns to skip directories when walking over the filesystem.