Initial commit
This commit is contained in:
32
Config/Config.go
Normal file
32
Config/Config.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user