apparmor.d/pkg/paths
2024-10-05 23:03:41 +01:00
..
testdata chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
constructors.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
list.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
list_test.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
paths.go chore: correct misspelled english words 2024-07-05 16:00:54 +01:00
paths_test.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
process.go build: update path helpers 2024-10-05 23:03:41 +01:00
process_linux.go build: update path helpers 2024-10-05 23:03:41 +01:00
process_test.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
readdir.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
readdir_test.go chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00
README.md chore: include build dep go-paths-helper. 2024-04-28 00:30:59 +01:00

paths: a golang library to simplify handling of paths

This library aims to simplify handling of the most common operations with paths.

For example code that looked like this:

buildPath := getPathFromSomewhere() // returns string
if buildPath != "" {
	cachePath, err := filepath.Abs(filepath.Join(buildPath, "cache"))
	...
}

can be transformed to:

buildPath := getPathFromSomewhere() // returns *paths.Path
if buildPath != nil {
	cachePath, err := buildPath.Join("cache").Abs()
	...
}

most operations that usually requires a bit of convoluted system calls are now simplified, for example to check if a path is a directory:

buildPath := "/path/to/somewhere"
srcPath := filepath.Join(buildPath, "src")
if info, err := os.Stat(srcPath); err == nil && !info.IsDir() {
    os.MkdirAll(srcPath)
}

using this library can be done this way:

buildPath := paths.New("/path/to/somewhere")
srcPath := buildPath.Join("src")
if !srcPath.IsDir() {
    scrPath.MkdirAll()
}

Security

If you think you found a vulnerability or other security-related bug in this project, please read our security policy and report the bug to our Security Team 🛡️ Thank you!

e-mail contact: security@arduino.cc