mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-10 03:03:04 +00:00
update dependencies - change imports
This commit is contained in:
47
config/config.go
Normal file
47
config/config.go
Normal file
@@ -0,0 +1,47 @@
|
||||
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"`
|
||||
RoomIDList []string `json:"RoomIDList"`
|
||||
RoleToNotify string `json:"RoleToNotify"`
|
||||
Servers []server `json:"Servers"`
|
||||
GameStatus string `json:"GameStatus"`
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user