aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/main.go
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-07-19 17:13:22 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-07-19 17:13:22 +0100
commit12e7a848918f2c1dc08731e78ee3697762020393 (patch)
treedb6b519bf4e9c163812ad2d0b5a180e4fccec5c2 /cmd/main.go
parent55cd31b37a4cdb81a3cef914acc53f80560c74d0 (diff)
started to build main
Diffstat (limited to 'cmd/main.go')
-rw-r--r--cmd/main.go38
1 files changed, 36 insertions, 2 deletions
diff --git a/cmd/main.go b/cmd/main.go
index 525191f..2343007 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -1,6 +1,40 @@
+/*
+datamaps-go is a simple tool to extract from and send data to spreadsheets.
+*/
package main
+import (
+ "fmt"
+ "log"
+ "os"
+ "path/filepath"
+)
+
+func createConfigDir() (string, error) {
+ dir, err := os.UserConfigDir()
+ if err != nil {
+ return "", err
+ }
+ // check if config folder exists
+ config_path := filepath.Join(dir, "datamaps-go")
+ if _, err := os.Stat(config_path); os.IsNotExist(err) {
+ log.Println("Config directory does not exist.")
+ log.Println("Creating config directory.")
+ if err := os.Mkdir(filepath.Join(dir, "datamaps-go"), 0700); err != nil {
+ return "", err
+ }
+ } else {
+ log.Println("Config directory found.")
+ }
+ return dir, nil
+}
+
+// Entry point
+
func main() {
- //reader.ReadDML("/home/lemon/Documents/datamaps/input/datamap.csv")
- //reader.ReadXLSX("/home/lemon/Documents/datamaps/input/A417%20Air%20Balloon_Q1%20Apr%20-%20June%202019_Return.xlsm")
+ dir, err := createConfigDir()
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(dir)
}