Using reader for reading config file
This commit is contained in:
+3
-3
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user