mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +08:00
rewrote HOME dir lookup (no cgo)
This commit is contained in:
@ -22,8 +22,6 @@ NOTES:
|
|||||||
all dependencies.
|
all dependencies.
|
||||||
* Package managers often contain out-of-date `golang` packages.
|
* Package managers often contain out-of-date `golang` packages.
|
||||||
Compilation from source is recommended.
|
Compilation from source is recommended.
|
||||||
* go-ipfs depends on cgo. In case you've disabled cgo, you'll need to
|
|
||||||
compile with `CGO_ENABLED=1`
|
|
||||||
* If you are interested in development, please install the development
|
* If you are interested in development, please install the development
|
||||||
dependencies as well.
|
dependencies as well.
|
||||||
* **WARNING: older versions of OSX FUSE (for Mac OS X) can cause kernel panics when mounting!**
|
* **WARNING: older versions of OSX FUSE (for Mac OS X) can cause kernel panics when mounting!**
|
||||||
|
10
util/util.go
10
util/util.go
@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os/user"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -35,13 +35,7 @@ var ErrNotFound = ds.ErrNotFound
|
|||||||
// TildeExpansion expands a filename, which may begin with a tilde.
|
// TildeExpansion expands a filename, which may begin with a tilde.
|
||||||
func TildeExpansion(filename string) (string, error) {
|
func TildeExpansion(filename string) (string, error) {
|
||||||
if strings.HasPrefix(filename, "~/") {
|
if strings.HasPrefix(filename, "~/") {
|
||||||
usr, err := user.Current()
|
filename = strings.Replace(filename, "~", os.Getenv("HOME"), 1)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
dir := usr.HomeDir + "/"
|
|
||||||
filename = strings.Replace(filename, "~/", dir, 1)
|
|
||||||
}
|
}
|
||||||
return filename, nil
|
return filename, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user