Skip to content

arduino/go-paths-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

73c658f · Apr 10, 2025
Dec 4, 2023
Jan 15, 2024
May 20, 2018
Mar 9, 2021
May 19, 2021
Dec 7, 2023
Dec 7, 2023
Dec 7, 2023
Dec 4, 2023
Jul 2, 2018
Jan 15, 2024
Dec 19, 2023
Jan 15, 2024
Jan 15, 2024
Apr 10, 2025
Jun 4, 2024
Jun 4, 2024
Jun 4, 2024
Jun 4, 2024
Jan 12, 2024
Jan 15, 2024

Repository files navigation

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