Added Path utility

This commit is contained in:
obscuren 2014-07-01 20:08:18 +02:00
parent 7a9ff4f8d4
commit 3889785017
1 changed files with 20 additions and 0 deletions

20
ethutil/path.go Normal file
View File

@ -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
}