Guest User

Untitled

a guest
Aug 10th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. // Load the JSON config file
  2. func Load(configFile string, outputObj interface{}) *errors.ErrorSt {
  3. var err error
  4. // Read the config file
  5. jsonBytes, err := ioutil.ReadFile(configFile)
  6. if err != nil {
  7. fmt.Println(err.Error())
  8. return errors.File().AddDetails(err.Error())
  9. }
  10.  
  11. // Parse the config
  12. if err := json.Unmarshal(jsonBytes, outputObj); err != nil {
  13. return errors.JSON().AddDetails("Could not parse" + configFile + ": " + err.Error())
  14. }
  15. return nil
  16.  
  17. }
Add Comment
Please, Sign In to add comment