Basic project structure

This commit is contained in:
2022-08-31 19:56:06 -04:00
parent d99784e613
commit a8df1d0ab3
8 changed files with 592 additions and 1 deletions

23
util/env.go Normal file
View File

@ -0,0 +1,23 @@
package util
import (
"path/filepath"
"os/user"
"strings"
)
func ResolveTilde(path string) string {
usr, _ := user.Current()
dir := usr.HomeDir
if path == "~" {
// In case of "~", which won't be caught by the "else if"
path = dir
} else if strings.HasPrefix(path, "~/") {
// Use strings.HasPrefix so we don't match paths like
// "/something/~/something/"
path = filepath.Join(dir, path[2:])
}
return path
}