File: README.md

package info (click to toggle)
golang-github-arduino-go-paths-helper 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 248 kB
  • sloc: makefile: 7
file content (51 lines) | stat: -rw-r--r-- 1,298 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## 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