Skip to content

lwileczek/goFind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Find

A file finder written in Go.

Uses a worker pool to search through directory trees quicker by taking advantage of multi-core machines. Go concurrency allows it to run on single core machines.

Each worker reads all of the items in a single directory. If one of the items is itself a directory, it's added to the work queue and another worker will begin searching that directory.

Features

  • Concurrency search directories for desired pattern
  • Exit early with a max results option
  • Common paths are ignored to save time and checks, such as node_modules, .git, and python venv.
  • Searches for a pattern using basic sub-string
  • Use a worker pool to avoid spinning up too many go routines if there are many directories

Warning

warning Does not work on windows and I'm not trying too support this

Using

Usage

Customise your search with the following flags

Usage: goFind [OPTIONS] <pattern> <path>
  set pattern & path positionally or via flags
  -c int
        The maximum number of results to find (default -1)
  -d string
        The starting directory to check for files (default ".")
  -i    perform a case insensative search
  -p string
        A pattern to check for within the file names
  -q int
        The max work queue size (default 512)
  -v    print the version and build information
  -w int
        Number of workers (default -1)

Contributing

Build

build with go build -o gf main.go and run with ./gf -d <starting-path> -p <pattern-to-match-on>

Requirements

  • Go 1.21+

Makefile

You can use the makefile to build a production release with make build

Requirements

  • Make
  • Go 1.21+

Roadmap

  • can we create a worker pool instead of the number of initial directories
  • cap the number of returned responses, say 1 (quit after the first match!)
  • Auto-generate releases
  • cap the depth of the search
  • use select statement with a fallback queue to prevent deadlock from happening
  • use postional args or flags to set the pattern/path
  • Add flag to print which paths will be ignored
  • create case sensative/insensative searching
  • exclude additional directories or patters
  • include specific patterns in the search path
  • switch to ignore all hidden files/directories
  • look for .gitignore files and use contents to build ignored patterns

About

unix Find but bespoke for my personal needs

Resources

Stars

Watchers

Forks

Packages

No packages published