提交 960996d1 作者: Henry

simplify TildeExpansion()

上级 320ac339
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"io" "io"
"math/rand" "math/rand"
"path/filepath" "path/filepath"
"strings"
"time" "time"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go" ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
...@@ -34,14 +33,7 @@ var ErrNotFound = ds.ErrNotFound ...@@ -34,14 +33,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, "~/") { return homedir.Expand(filename)
var err error
filename, err = homedir.Expand(filename)
if err != nil {
return "", err
}
}
return filename, nil
} }
// ExpandPathnames takes a set of paths and turns them into absolute paths // ExpandPathnames takes a set of paths and turns them into absolute paths
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论