osexistpath
is designed to check whether a path, file, or directory exists.
- IsPathExists: Checks whether a path exists.
- IsFileExists: Checks whether a file exists.
- IsRootExists: Checks is a directory exists.
- PATH, FILE, ROOT: Functions that return the path if it exists, otherwise raise a panic.
go get github.com/yyle88/osexistpath
package main
import (
"fmt"
"github.com/yyle88/osexistpath"
)
func main() {
// Check if a path exists using the "Might" verbosity level
path := "/some/path"
exist, err := osexistpath.IsPathExists(path, osexistpath.Might)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("Path exists:", exist)
}
}
package main
import (
"fmt"
"github.com/yyle88/osexistpath"
)
func main() {
// Check if a file exists using the "Sweet" verbosity level
file := "/some/file.txt"
exist, err := osexistpath.IsFileExists(file, osexistpath.Sweet)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("File exists:", exist)
}
}
package main
import (
"fmt"
"github.com/yyle88/osexistpath"
)
func main() {
// Check if a directory exists using the "Noisy" verbosity level
dir := "/some/directory"
exist, err := osexistpath.IsRootExists(dir, osexistpath.Noisy)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("Directory exists:", exist)
}
}
osexistpath
is open-source and released under the MIT License. See the LICENSE file for more information.
Welcome to contribute to this project by submitting pull requests or reporting issues.
If you find this package helpful, give it a star on GitHub!
Thank you for your support!
Happy Coding with osexistpath
! 🎉
Give me stars. Thank you!!!