MQTTListener/Config/Config.go
2020-08-26 09:54:26 +02:00

33 lines
752 B
Go

package Config
import (
//"fmt"
"log"
"github.com/pelletier/go-toml"
)
var BrokerAddress = ""
var BrokerPort int64 = 8883
var BrokerClientId = "go_client"
var BrokerUsername = ""
var BrokerPassword = ""
var EnableTLS = true
func ReadConfig() {
config, err := toml.LoadFile("config.toml")
if err != nil {
//fmt.Println("Error ", err.Error())
log.Fatal(err.Error())
} else {
// retrieve data directly
BrokerAddress = config.Get("BROKER.Address").(string)
BrokerPort = config.Get("BROKER.Port").(int64)
BrokerClientId = config.Get("BROKER.ClientId").(string)
BrokerUsername = config.Get("BROKER.Username").(string)
BrokerPassword = config.Get("BROKER.Password").(string)
EnableTLS = config.Get("BROKER.EnableTLS").(bool)
}
}