Replace user.Home() with os.HomeDir() to remove CGo dependency (hopefully)

This commit is contained in:
Seednode 2023-09-13 12:46:14 -05:00
parent 65b77f33cc
commit d2d9418b8b
2 changed files with 4 additions and 5 deletions

View File

@ -8,7 +8,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"math/big" "math/big"
"os/user"
"regexp" "regexp"
"crypto/rand" "crypto/rand"
@ -604,15 +603,15 @@ func pickFile(args []string, filters *filters, sort string, cache *fileCache, fo
} }
func normalizePath(path string) (string, error) { func normalizePath(path string) (string, error) {
usr, err := user.Current() homeDir, err := os.UserHomeDir()
if err != nil { if err != nil {
return "", err return "", err
} }
if path == "~" { if path == "~" {
path = usr.HomeDir path = homeDir
} else if strings.HasPrefix(path, "~/") { } else if strings.HasPrefix(path, "~/") {
path = filepath.Join(usr.HomeDir, path[2:]) path = filepath.Join(homeDir, path[2:])
} }
path, err = filepath.EvalSymlinks(path) path, err = filepath.EvalSymlinks(path)

View File

@ -12,7 +12,7 @@ import (
) )
const ( const (
ReleaseVersion string = "0.78.1" ReleaseVersion string = "0.78.2"
) )
var ( var (