From 38f99009012f0336bc6beb0be674b554d5bdd0b8 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Wed, 15 Feb 2023 01:15:59 +0300 Subject: [PATCH] fix naming and error return in json read util --- osutils/json.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osutils/json.go b/osutils/json.go index 522e789..dde5d4d 100644 --- a/osutils/json.go +++ b/osutils/json.go @@ -7,10 +7,10 @@ import ( "os" ) -func WriteStructAsJSON(data interface{}, versionJsonPath string) error { +func WriteStructAsJSON(data interface{}, JsonPath string) error { file, _ := json.MarshalIndent(data, "", " ") - directory, err := GetParentDir(versionJsonPath) + directory, err := GetParentDir(JsonPath) if err != nil { return err } @@ -18,7 +18,7 @@ func WriteStructAsJSON(data interface{}, versionJsonPath string) error { if err != nil { return err } - err = ioutil.WriteFile(versionJsonPath, file, 0644) + err = ioutil.WriteFile(JsonPath, file, 0644) if err != nil { return err } @@ -31,6 +31,7 @@ func ReadJsonFromDisk(target interface{}, filePath string) error { // if we os.Open returns an error then handle it if err != nil { fmt.Println(err) + return err } // fmt.Println("Successfully Opened users.json")