github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/repo/fsrepo/misc.go (about) 1 package fsrepo 2 3 import ( 4 "os" 5 6 homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir" 7 "github.com/ipfs/go-ipfs/repo/config" 8 ) 9 10 // BestKnownPath returns the best known fsrepo path. If the ENV override is 11 // present, this function returns that value. Otherwise, it returns the default 12 // repo path. 13 func BestKnownPath() (string, error) { 14 ipfsPath := config.DefaultPathRoot 15 if os.Getenv(config.EnvDir) != "" { 16 ipfsPath = os.Getenv(config.EnvDir) 17 } 18 ipfsPath, err := homedir.Expand(ipfsPath) 19 if err != nil { 20 return "", err 21 } 22 return ipfsPath, nil 23 }