A simple library to handle file path input in Go.
- Hanlde absolute and relative paths
- Globbing (must be quoted)
- List files in directories recursivly
- Optional regex to filter results
- Cli via flag, see example
When passing in globbed patterns via cli you must quote them, if you dont bash will expand them and could result in undesired results.
go run cmd/main.go -path "/my/globbed/path/*"
package main
import (
"flag"
"fmt"
"github.com/kmulvey/path"
)
func main() {
var files path.Entry
flag.Var(&files, "path", "path to files")
flag.Parse()
fmt.Println("user input: ", files.AbsolutePath)
fmt.Println("number of files found within this path: ", len(files.Children))
}