mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-12 11:48:07 +08:00
24 lines
594 B
Go
24 lines
594 B
Go
package fsrepo
|
|
|
|
import (
|
|
"os"
|
|
|
|
homedir "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
|
|
"github.com/jbenet/go-ipfs/repo/config"
|
|
)
|
|
|
|
// BestKnownPath returns the best known fsrepo path. If the ENV override is
|
|
// present, this function returns that value. Otherwise, it returns the default
|
|
// repo path.
|
|
func BestKnownPath() (string, error) {
|
|
ipfsPath := config.DefaultPathRoot
|
|
if os.Getenv(config.EnvDir) != "" {
|
|
ipfsPath = os.Getenv(config.EnvDir)
|
|
}
|
|
ipfsPath, err := homedir.Expand(ipfsPath)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return ipfsPath, nil
|
|
}
|