diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-07-24 10:12:01 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-07-24 10:12:01 +0100 |
commit | 36f3983b039905c54a957f236e4a9718ea7c918f (patch) | |
tree | 46c5424ed0930a7dfbf54ca0f77d05924fc96f01 /cmd/datamaps | |
parent | 3b82b7463987ff637530cb403b6d294978bbd115 (diff) |
mostly linting
Diffstat (limited to 'cmd/datamaps')
-rw-r--r-- | cmd/datamaps/main.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/datamaps/main.go b/cmd/datamaps/main.go index 32b7ce8..b0d1c1d 100644 --- a/cmd/datamaps/main.go +++ b/cmd/datamaps/main.go @@ -26,34 +26,41 @@ func setUp() (string, error) { // check if config folder exists configPath := filepath.Join(dir, configDirName) dbPath := filepath.Join(configPath, dbName) + if _, err := os.Stat(configPath); os.IsNotExist(err) { log.Println("Config directory does not exist.") log.Printf("Creating config directory %s\n", configPath) + if err := os.Mkdir(filepath.Join(dir, "datamaps-go"), 0700); err != nil { return "", err } } else { log.Println("Config directory found.") } + if _, err := os.Stat(dbPath); os.IsNotExist(err) { log.Println("Database does not exist.") + _, err = os.Create(dbPath) + if err != nil { return "", err } + log.Printf("Creating database file at %s\n", dbPath) _, err := datamaps.SetupDB(dbPath) + if err != nil { return "", err } } else { log.Println("Database file found.") } + return dir, nil } func main() { - opts := datamaps.ParseOptions() switch opts.Command { |