1
0
mirror of https://github.com/mgerb/ServerStatus synced 2026-01-10 03:03:04 +00:00
This commit is contained in:
2017-01-15 22:10:35 +01:00
commit a2f39bdcc4
7 changed files with 254 additions and 0 deletions

45
config/config.go Normal file
View File

@@ -0,0 +1,45 @@
package config
import (
"encoding/json"
"io/ioutil"
"log"
"os"
)
// Variables used for command line parameters
var Config configStruct
type configStruct struct {
Token string `json:"Token"`
AlertRoomID string `json:"AlertRoomID"`
Servers []server `json:"Servers"`
}
type server struct {
Name string `json:"Name"`
Address string `json:"Address"`
Port int `json:"Port"`
Online bool `json:"Online,omitempty"`
}
func Configure() {
log.Println("Reading config file...")
file, e := ioutil.ReadFile("./config.json")
if e != nil {
log.Printf("File error: %v\n", e)
os.Exit(1)
}
log.Printf("%s\n", string(file))
err := json.Unmarshal(file, &Config)
if err != nil {
log.Println(err)
}
}