HDFSWriter microservice working copy
[demo.git] / vnfs / DAaaS / microservices / GoApps / src / go-hdfs-writer / pkg / utils / readJson.go
1 package utils
2
3 import (
4         "os"
5         "io/ioutil"
6 )
7
8
9 //ReadJSON reads the content of a give file and returns as a string
10 // used for small config files only.
11 func ReadJSON(path string) string {
12         slogger := GetLoggerInstance()
13         jsonFile, err := os.Open(path)
14         if err!=nil{
15                 //fmt.Print(err)
16                 slogger.Errorf("Unable to open file: %s", path)
17                 slogger.Errorf("Error::: %s", err)
18
19         }else{
20                 slogger.Infof("Successfully opened config.json")
21         }
22         
23         defer jsonFile.Close()
24         byteValue, _ := ioutil.ReadAll(jsonFile)
25         s := string(byteValue)
26         return s
27 }
28