1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 }