diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-02 02:08:18 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-02 02:08:18 +0800 |
commit | 3889785017a1381d215cb1dc47fd5fb5b38add79 (patch) | |
tree | bf3975b1947201dc601a289c60fdd0848b093913 /ethutil | |
parent | 7a9ff4f8d45e741625bc32fde59b3dfe90851492 (diff) | |
download | go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.tar go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.tar.gz go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.tar.bz2 go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.tar.lz go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.tar.xz go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.tar.zst go-tangerine-3889785017a1381d215cb1dc47fd5fb5b38add79.zip |
Added Path utility
Diffstat (limited to 'ethutil')
-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 +} |