Skip to content
Permalink
Browse files
This closes #9
  • Loading branch information
aledsage committed Mar 19, 2016
2 parents bf696e5 + daf8fea commit 285013a19abad7f4bcb224e77ce2a86fcb38ea52
Showing 1 changed file with 5 additions and 2 deletions.
@@ -20,9 +20,10 @@ package io

import (
"encoding/json"
"github.com/apache/brooklyn-client/error_handler"
"os"
"path/filepath"

"github.com/apache/brooklyn-client/error_handler"
)

type Config struct {
@@ -48,12 +49,12 @@ func GetConfig() (config *Config) {
}

func (config *Config) Write() {

// Create file as read/write by user (but does not change perms of existing file)
fileToWrite, err := os.OpenFile(config.FilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
error_handler.ErrorExit(err)
}
defer fileToWrite.Close()

enc := json.NewEncoder(fileToWrite)
enc.Encode(config.Map)
@@ -64,6 +65,8 @@ func (config *Config) Read() {
if err != nil {
error_handler.ErrorExit(err)
}
defer fileToRead.Close()

dec := json.NewDecoder(fileToRead)
dec.Decode(&config.Map)
}

0 comments on commit 285013a

Please sign in to comment.