mirror of
https://github.com/zu1k/nali.git
synced 2025-01-22 21:29:02 +08:00
29 lines
493 B
Go
29 lines
493 B
Go
|
package constant
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
// HomePath database home path
|
||
|
HomePath string
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
HomePath = os.Getenv("NALI_DB_HOME")
|
||
|
if HomePath == "" {
|
||
|
homeDir, err := os.UserHomeDir()
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
HomePath = filepath.Join(homeDir, ".nali")
|
||
|
}
|
||
|
if _, err := os.Stat(HomePath); os.IsNotExist(err) {
|
||
|
if err := os.MkdirAll(HomePath, 0777); err != nil {
|
||
|
log.Fatal("can not create", HomePath, ", use bin dir instead")
|
||
|
}
|
||
|
}
|
||
|
}
|