Simple go library for validating file and directory existence
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
example_test.go
fval.go
fval_test.go

README.md

Build Status Coverage Godoc license Go Report Card

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/fval

Usage

// 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 -cover

Contributing

All contributions are welcome! See CONTRIBUTING for more info.

License

The code is under the MIT license. See LICENSE for more information.