https://github.com/arduino/go-paths-helper
https://github.com/arduino/go-paths-helper
golang tooling-team
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arduino/go-paths-helper
- Owner: arduino
- License: gpl-2.0
- Created: 2018-05-19T11:07:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T12:06:13.000Z (over 1 year ago)
- Last Synced: 2025-01-29T10:51:30.530Z (8 months ago)
- Topics: golang, tooling-team
- Language: Go
- Homepage:
- Size: 120 KB
- Stars: 6
- Watchers: 8
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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:
```go
buildPath := getPathFromSomewhere() // returns string
if buildPath != "" {
cachePath, err := filepath.Abs(filepath.Join(buildPath, "cache"))
...
}
```can be transformed to:
```go
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:
```go
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:
```go
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](https://github.com/arduino/go-paths-helper/security/policy) and report the bug to our Security Team 🛡️
Thank you!e-mail contact: security@arduino.cc