diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-07-24 15:28:02 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-07-24 15:28:02 +0100 |
commit | 5a30da3fbdab17ecbcacb09b38d4cd9faf9e3044 (patch) | |
tree | c359082012e70029f4c77652c6eb85dbc84f63fd | |
parent | 594f81b04c7d9194274395c06ffaf6b51d87e441 (diff) |
starting to add new code
-rw-r--r-- | cmd/datamaps/main.go | 4 | ||||
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | pkg/datamaps/config.go | 9 |
3 files changed, 14 insertions, 2 deletions
diff --git a/cmd/datamaps/main.go b/cmd/datamaps/main.go index 74a8133..cc634a6 100644 --- a/cmd/datamaps/main.go +++ b/cmd/datamaps/main.go @@ -12,6 +12,10 @@ import ( ) func main() { + env := datamaps.DetectConfig() + if !env { + datamaps.SetUp() + } opts := datamaps.ParseOptions() switch opts.Command { @@ -3,9 +3,8 @@ module github.com/yulqen/datamaps-go go 1.14 require ( - github.com/cweill/gotests v1.5.3 // indirect github.com/mattn/go-sqlite3 v1.14.0 github.com/tealeg/xlsx v1.0.5 - github.com/urfave/cli/v2 v2.2.0 github.com/yulqen/coords v0.1.0 + golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305 // indirect ) diff --git a/pkg/datamaps/config.go b/pkg/datamaps/config.go index 713ad5a..687166c 100644 --- a/pkg/datamaps/config.go +++ b/pkg/datamaps/config.go @@ -11,6 +11,15 @@ const ( dbName = "datamaps.db" ) +// DetectConfig looks for the configuration directory and +// files, and the database file needed to run the application. +func DetectConfig() bool { + dir, err := os.UserConfigDir() + if err != nil { + return "", err + } +} + // SetUp creates the config directory and requisite files func SetUp() (string, error) { dir, err := os.UserConfigDir() |