From 3889785017a1381d215cb1dc47fd5fb5b38add79 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 1 Jul 2014 20:08:18 +0200 Subject: [PATCH] Added Path utility --- ethutil/path.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ethutil/path.go diff --git a/ethutil/path.go b/ethutil/path.go new file mode 100644 index 0000000000..97f58ab7e5 --- /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 +}