Load units from config
This commit is contained in:
parent
fccc4df352
commit
d88b952e9d
|
@ -2,6 +2,8 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/localhots/yeast/impl"
|
"github.com/localhots/yeast/impl"
|
||||||
"github.com/localhots/yeast/unit"
|
"github.com/localhots/yeast/unit"
|
||||||
|
@ -11,7 +13,16 @@ var (
|
||||||
Units = map[string]Caller{}
|
Units = map[string]Caller{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoadUnits(b []byte) {
|
func LoadUnits() {
|
||||||
|
f, err := os.Open(Conf().UnitsConfig)
|
||||||
|
if err != nil {
|
||||||
|
panic("Failed to open units config: " + Conf().UnitsConfig)
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadAll(f)
|
||||||
|
if err != nil {
|
||||||
|
panic("Failed to parse units config: " + Conf().UnitsConfig)
|
||||||
|
}
|
||||||
|
|
||||||
var conf map[string]map[string]interface{}
|
var conf map[string]map[string]interface{}
|
||||||
json.Unmarshal(b, &conf)
|
json.Unmarshal(b, &conf)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue