diff options
Diffstat (limited to 'ethutil/path.go')
-rw-r--r-- | ethutil/path.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ethutil/path.go b/ethutil/path.go new file mode 100644 index 000000000..97f58ab7e --- /dev/null +++ b/ethutil/path.go @@ -0,0 +1,20 @@ +package ethutil + +import ( + "os/user" + "strings" +) + +func ExpandHomePath(p string) (path string) { + path = p + + // Check in case of paths like "/something/~/something/" + if path[:2] == "~/" { + usr, _ := user.Current() + dir := usr.HomeDir + + path = strings.Replace(p, "~", dir, 1) + } + + return +} |