Added Path utility
This commit is contained in:
parent
7a9ff4f8d4
commit
3889785017
20
ethutil/path.go
Normal file
20
ethutil/path.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user