spacepanel_aggregator/setup.go

48 lines
796 B
Go
Raw Normal View History

2020-01-30 17:34:56 +00:00
package spacepanel_aggregator
import (
"fmt"
yaml "gopkg.in/yaml.v2"
io "io/ioutil"
)
var listen = ":8080"
var conffile = "conf.yml"
var leds [][]string
func SetConf(s string) {
conffile = s
}
func SetIf(s string) {
listen = s
}
func Start() {
fmt.Println("Welcome to Spacepanel Aggregator!\n")
fmt.Println("Listen Interface: ", listen)
fmt.Println("Config-File: ", conffile)
bytes, err := io.ReadFile(conffile)
if err != nil {
ce(err)
}
err = yaml.Unmarshal(bytes, &leds)
if err != nil {
ce(err)
}
fmt.Println("So, lief anscheinend durch, schüss")
for i := 0; i < len(leds); i++ {
fmt.Println("-")
for j := 0; j < len(leds[i]); j++ {
fmt.Println(" -", leds[i][j])
}
}
}
func ce(err error) {
if err != nil {
fmt.Println("ERROR: ", err.Error())
}
}