2022-01-14 08:10:05 +00:00
|
|
|
package cache
|
2020-10-20 03:46:44 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
2020-10-20 03:48:44 +00:00
|
|
|
func prepareDir(p string) string {
|
|
|
|
_, err := os.Stat(p)
|
|
|
|
if err != nil {
|
|
|
|
_ = os.Mkdir(p, 0777)
|
|
|
|
}
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func CacheDir() string {
|
|
|
|
home := HomeDir()
|
|
|
|
dir := path.Join(home, "cache")
|
|
|
|
return prepareDir(dir)
|
|
|
|
}
|
|
|
|
|
2020-10-20 03:46:44 +00:00
|
|
|
func HomeDir() string {
|
|
|
|
homeDir, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2020-10-20 03:48:44 +00:00
|
|
|
dir := path.Join(homeDir, ".bbgo")
|
|
|
|
return prepareDir(dir)
|
2020-10-20 03:46:44 +00:00
|
|
|
}
|