mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 11:03:53 +00:00
37 lines
495 B
Go
37 lines
495 B
Go
package bbgo
|
|
|
|
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 SourceDir() string {
|
|
home := HomeDir()
|
|
return path.Join(home, "source")
|
|
}
|
|
|
|
func HomeDir() string {
|
|
homeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
dir := path.Join(homeDir, ".bbgo")
|
|
return prepareDir(dir)
|
|
}
|