31 lines
433 B
Go
31 lines
433 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
Secret string
|
||
|
BindHost string
|
||
|
BindPort string
|
||
|
}
|
||
|
|
||
|
func getConfig() Config {
|
||
|
f, err := os.Open("config.json")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
defer f.Close()
|
||
|
out := Config{}
|
||
|
data, err := ioutil.ReadAll(f)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
json.Unmarshal(data, &out)
|
||
|
return out
|
||
|
}
|