fval
Simple package for validating file and directory existence, eg. input to CLI applications. Originally built for go-arg - Pull request. The pull request was not accepted as go-arg is to be kept minimal, so this is extracted to a separate package. The usage is of course not limited to CLI application input, it is general purpose, but was built with CLI input in mind.
Installation
$ go get github.com/walle/fvalUsage
// CLI application with usage: example INPUTFILE OUTPUTDIR
if !fval.FileExists(os.Args[1]) {
fmt.Fprintf(os.Stderr, "Usage error: %s is not a valid file", os.Args[1])
os.Exit(1)
}
fval.DirExistsOrCreate(os.Args[2], 0766)Testing
Use the go test tool.
$ go test -coverContributing
All contributions are welcome! See CONTRIBUTING for more info.
License
The code is under the MIT license. See LICENSE for more information.