Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exclude ¶
Exclude represents a file or directory that should be excluded from a search. It contains a fs.DirEntry and the Path of the file or directory. It is used as an argument for Skip's Dir and File functions to determine if a file or directory should be skipped during a search.
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder searches a Go repository for Go types and functions that are exported and optionally not commented. Use New to create a new Finder, providing the fs.FS of the repository to search and zero or more options. Call All or Uncommented on a Finder to search the repository for all types/functions or only uncommented types/functions, respectively.
func New ¶
New returns a new *Finder that searches for types and functions in a given repository. It accepts an fs.FS representing the repository and zero or more Options to configure the search. The returned Finder can be used to search for all types and functions or only those without comments.
func (*Finder) All ¶
All returns a map of Findings(#Finding) for all exported types and functions in the repository.
func (*Finder) Uncommented ¶
Uncommented returns all [Finding]s of uncommented types and functions in the file system under the specified path.
type Finding ¶
Finding represents a type that contains information about code entities found in a file. It has two fields: Path and Identifier, where Path is the path of the file where the code entity was found and Identifier is the name of the code entity.
type Findings ¶
Findings [type] represents a map of file paths to slices of Findings. A Finding is a struct that contains the path to a Go source file and an exported identifier within that file. Use the Finder type to search for uncommented code in a filesystem, returning Findings for all or just uncommented types/functions.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an interface for configuring a *Finder.
func Glob ¶
Glob returns an Option that appends one or more glob patterns to the Finder. The Finder will exclude files and directories that match any of the glob patterns.
func WithLogger ¶
WithLogger returns an Option that sets the logger for a Finder. The logger is used to log debug, info and error messages during file searching.
type Skip ¶
type Skip struct { Hidden bool Dotfiles bool Testdata bool Testfiles bool Tests bool Dir func(Exclude) bool File func(Exclude) bool }
Skip represents a set of rules for excluding directories and files during a file system traversal. It contains fields for excluding hidden files, dotfiles, test data directories, and test files. It also includes functions for customizing directory and file exclusion behavior. Skip is used by Finder to avoid traversing unwanted directories and files.
func SkipDefault ¶
func SkipDefault() Skip
SkipDefault returns a Skip object with default values set for skipping hidden files and directories, dotfiles, testdata, and testfiles. It can be used as a starting point for creating custom Skip objects. Exclude objects can be passed to Skip methods to check if a file or directory should be excluded during a file search.
func SkipNone ¶
func SkipNone() Skip
SkipNone returns a Skip value with all of its fields set to their zero value. It is used to indicate that no files or directories should be skipped during the search.
func (Skip) ExcludeDir ¶
ExcludeDir returns a boolean indicating whether a directory should be excluded from the search. An Exclude struct with the directory's DirEntry and Path is passed as an argument. This function checks if the directory name starts with a dot when Skip.Hidden is set to true, or if it matches the "testdata" folder when Skip.Testdata is set to true. If Skip.Dir is not nil, it also calls that function to determine if the directory should be skipped.
func (Skip) ExcludeFile ¶
ExcludeFile returns a boolean indicating whether the file should be excluded from the search. The exclusion criteria are based on the Skip struct's Dotfiles, Testfiles, and File fields. If Dotfiles is true, files with names starting with a dot (".") are excluded. If Testfiles is true, files with names ending in "_test.go" are excluded. Finally, if the File field of Skip is not nil, it will be called with the fs.DirEntry wrapped in an Exclude struct to determine whether the file should be excluded.