nali/main.go

33 lines
565 B
Go
Raw Normal View History

2020-07-17 01:41:09 +00:00
package main
2020-07-17 01:05:25 +00:00
2020-07-17 01:41:09 +00:00
import (
"log"
"os"
"path/filepath"
2020-07-17 01:05:25 +00:00
2020-07-17 01:41:09 +00:00
"github.com/zu1k/nali/internal/app"
2020-07-17 01:05:25 +00:00
2020-07-17 01:41:09 +00:00
"github.com/zu1k/nali/cmd"
"github.com/zu1k/nali/constant"
)
2020-07-17 01:05:25 +00:00
func main() {
2020-07-17 01:41:09 +00:00
setHomePath()
app.InitIPDB()
2020-07-17 01:05:25 +00:00
cmd.Execute()
}
2020-07-17 01:41:09 +00:00
func setHomePath() {
homeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
}
homePath := filepath.Join(homeDir, ".nali")
constant.HomePath = homePath
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")
}
}
}