Using reader for reading config file

This commit is contained in:
claudemiro
2016-03-04 08:31:32 -03:00
parent 7dad2de275
commit 880d7bda2a
+3 -3
View File
@@ -6,9 +6,9 @@ package ipe
import (
"encoding/json"
"io/ioutil"
"math/rand"
"net/http"
"os"
"time"
log "github.com/golang/glog"
@@ -21,13 +21,13 @@ var conf configFile
// It Panic if could not start the HTTP or HTTPS server
func Start(configfile string) {
rand.Seed(time.Now().Unix())
file, err := ioutil.ReadFile(configfile)
file, err := os.Open(configfile)
if err != nil {
log.Fatal(err)
}
if err := json.Unmarshal(file, &conf); err != nil {
if err := json.NewDecoder(file).Decode(&conf); err != nil {
log.Fatal(err)
}