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 ( import (
"encoding/json" "encoding/json"
"io/ioutil"
"math/rand" "math/rand"
"net/http" "net/http"
"os"
"time" "time"
log "github.com/golang/glog" log "github.com/golang/glog"
@@ -21,13 +21,13 @@ var conf configFile
// It Panic if could not start the HTTP or HTTPS server // It Panic if could not start the HTTP or HTTPS server
func Start(configfile string) { func Start(configfile string) {
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().Unix())
file, err := ioutil.ReadFile(configfile) file, err := os.Open(configfile)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
if err := json.Unmarshal(file, &conf); err != nil { if err := json.NewDecoder(file).Decode(&conf); err != nil {
log.Fatal(err) log.Fatal(err)
} }