feat: paths

This commit is contained in:
Felipe M 2025-03-23 21:00:03 +01:00
parent 5cdbbd2296
commit 92732f9682
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8

20
paths/user.go Normal file
View file

@ -0,0 +1,20 @@
package paths
import (
"os/user"
"path/filepath"
"strings"
)
func ExpandUser(providedPath string) string {
var path string = providedPath
usr, _ := user.Current()
dir := usr.HomeDir
if providedPath == "~" {
path = dir
} else if strings.HasPrefix(providedPath, "~/") {
path = filepath.Join(dir, providedPath[2:])
}
return path
}