aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-08-01 19:25:16 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-08-01 19:28:05 +0100
commit1fa9157f4b035198ecdd93490e31301c1071317d (patch)
tree73f65b13de0908e42e61c81cfb08967e2484c482
parentadd51ef91b96e604c00b447f58d5df5fa638b90e (diff)
tidying linting and checker errors
-rw-r--r--pkg/datamaps/config.go7
-rw-r--r--pkg/datamaps/config_test.go4
-rw-r--r--pkg/datamaps/reader.go1
-rw-r--r--pkg/datamaps/writer.go5
-rw-r--r--pkg/datamaps/writer_test.go2
5 files changed, 13 insertions, 6 deletions
diff --git a/pkg/datamaps/config.go b/pkg/datamaps/config.go
index 7311fba..f370ba4 100644
--- a/pkg/datamaps/config.go
+++ b/pkg/datamaps/config.go
@@ -155,10 +155,13 @@ func defaultOptions() *Options {
}
dmPath, err := defaultDMPath()
- xlsxPath, err := defaultXLSXPath()
+ if err != nil {
+ log.Fatalf("unable to get default datamaps directory path: %v", err)
+ }
+ xlsxPath, err := defaultXLSXPath()
if err != nil {
- log.Fatalf("Unable to get default datamaps directory %v", err)
+ log.Fatalf("unable to get default XLSX directory path: %v", err)
}
homeDir, err := os.UserHomeDir()
diff --git a/pkg/datamaps/config_test.go b/pkg/datamaps/config_test.go
index 2dfa665..dadaf6d 100644
--- a/pkg/datamaps/config_test.go
+++ b/pkg/datamaps/config_test.go
@@ -20,7 +20,9 @@ func TestDBDetect(t *testing.T) {
t.Fatalf("cannot create temporary directory - %v", err)
}
- os.Create(filepath.Join("/tmp", "CONFIG", "datamaps", "datamaps.db"))
+ if _, err := os.Create(filepath.Join("/tmp", "CONFIG", "datamaps", "datamaps.db")); err != nil {
+ t.Fatalf("cannot open '/tmp/CONFIG/datamaps/databamps.db': %v", err)
+ }
defer func() {
os.RemoveAll(filepath.Join("/tmp", "CONFIG"))
}()
diff --git a/pkg/datamaps/reader.go b/pkg/datamaps/reader.go
index f1d0681..b6e43e8 100644
--- a/pkg/datamaps/reader.go
+++ b/pkg/datamaps/reader.go
@@ -48,7 +48,6 @@ type extractedCell struct {
var (
inner = make(sheetData)
- exc extractedCell
)
// ExtractedDatamapFile is a slice of datamapLine structs, each of which encodes a single line
diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go
index cff9f4e..d1da39f 100644
--- a/pkg/datamaps/writer.go
+++ b/pkg/datamaps/writer.go
@@ -15,6 +15,9 @@ import (
func ExportMaster(opts *Options) error {
wb := xlsx.NewFile()
sh, err := wb.AddSheet("Master Data")
+ if err != nil {
+ return fmt.Errorf("cannot add 'Master Data' sheet to new XLSX file: %v", err)
+ }
// SQLITE CODE
@@ -117,7 +120,7 @@ func ExportMaster(opts *Options) error {
func appendValueMap(k, v string, values map[string][]string) (map[string][]string, error) {
var keyIn bool
- for kv, _ := range values {
+ for kv := range values {
if kv == k {
keyIn = true
break
diff --git a/pkg/datamaps/writer_test.go b/pkg/datamaps/writer_test.go
index 4be87d9..319544c 100644
--- a/pkg/datamaps/writer_test.go
+++ b/pkg/datamaps/writer_test.go
@@ -33,7 +33,7 @@ func TestWriteMaster(t *testing.T) {
}()
if err := DatamapToDB(&opts); err != nil {
- t.Errorf("Unable to write datamap to database file because %v.", err)
+ t.Fatalf("Unable to write datamap to database file because %v.", err)
}
if err := ImportToDB(&opts); err != nil {