aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go
diff options
context:
space:
mode:
Diffstat (limited to 'vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go')
-rw-r--r--vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go
new file mode 100644
index 00000000..bfab64e6
--- /dev/null
+++ b/vnfs/DAaaS/microservices/GoApps/src/go-hdfs-writer/pkg/utils/readJson.go
@@ -0,0 +1,28 @@
+package utils
+
+import (
+ "os"
+ "io/ioutil"
+)
+
+
+//ReadJSON reads the content of a give file and returns as a string
+// used for small config files only.
+func ReadJSON(path string) string {
+ slogger := GetLoggerInstance()
+ jsonFile, err := os.Open(path)
+ if err!=nil{
+ //fmt.Print(err)
+ slogger.Errorf("Unable to open file: %s", path)
+ slogger.Errorf("Error::: %s", err)
+
+ }else{
+ slogger.Infof("Successfully opened config.json")
+ }
+
+ defer jsonFile.Close()
+ byteValue, _ := ioutil.ReadAll(jsonFile)
+ s := string(byteValue)
+ return s
+}
+