feat: cache + paths (#1)
- Added helper function `ExpandUser` - Added basic cache impmentations for in-memory and file based caches. Reviewed-on: #1 Co-authored-by: Felipe M. <me@fmartingr.com> Co-committed-by: Felipe M. <me@fmartingr.com>
This commit is contained in:
parent
ef80892aa5
commit
98eb17d9f3
10 changed files with 984 additions and 0 deletions
20
paths/user.go
Normal file
20
paths/user.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue