12 // MakeName creates a node name that follows the ethereum convention
13 // for such names. It adds the operation system name and Go runtime version
15 func MakeName(name, version string) string {
16 return fmt.Sprintf("%s/v%s/%s/%s", name, version, runtime.GOOS, runtime.Version())
19 func ExpandHomePath(p string) (path string) {
21 sep := string(os.PathSeparator)
23 // Check in case of paths like "/something/~/something/"
24 if len(p) > 1 && p[:1+len(sep)] == "~"+sep {
25 usr, _ := user.Current()
27 path = strings.Replace(p, "~", dir, 1)
32 func FileExist(filePath string) bool {
33 _, err := os.Stat(filePath)
34 if err != nil && os.IsNotExist(err) {
41 func AbsolutePath(Datadir string, filename string) string {
42 if filepath.IsAbs(filename) {
45 return filepath.Join(Datadir, filename)
48 func HomeDir() string {
49 if home := os.Getenv("HOME"); home != "" {
52 if usr, err := user.Current(); err == nil {