code: func expandPath(p string) string {
  	if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
  		if home := homeDir(); home != "" {
  			p = home + p[1:]
  		}
  	}
  	return path.Clean(os.ExpandEnv(p))
  }
docs: // Expands a file path
  // 1. replace tilde with users home dir
  // 2. expands embedded environment variables
  // 3. cleans the path, e.g. /a/b/../c -> /a/c
  // Note, it has limitations, e.g. ~someuser/tmp will not be expanded