31 lines
471 B
Go
31 lines
471 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
Secret string
|
|
BindHost string `json:"bind_host"`
|
|
BindPort string `json:"bind_port"`
|
|
}
|
|
|
|
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
|
|
}
|