mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-27 17:25:16 +00:00
32 lines
414 B
Go
32 lines
414 B
Go
package cache
|
|
|
|
import (
|
|
"os"
|
|
"path"
|
|
)
|
|
|
|
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)
|
|
}
|
|
|
|
func HomeDir() string {
|
|
homeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
dir := path.Join(homeDir, ".bbgo")
|
|
return prepareDir(dir)
|
|
}
|