package config import ( "encoding/json" "os" "log" ) type OIDTopicObject struct { OID string `json:"oid"` Label string `json:"label"` Diff string `json:"diff"` } // SNMPEndpointObject is the SNMP Endpoint definition type SNMPEndpointObject struct { Endpoint string `json:"endpoint"` Label string `json:"label"` Community string `json:"community"` OIDTopics []OIDTopicObject `json:"oidTopics"` } type MQTTConfigObject struct { Broker string `json:"broker"` Username string `json:"username"` Password string `json:"password"` TlsEnable string `json:"tlsEnable"` Topic string `json:"topic"` } type ConfigObject struct { Mqtt MQTTConfigObject `json:"mqtt"` Interval int `json:"interval"` SNMPEndpoints []SNMPEndpointObject `json:"snmpEndpoints"` } var Config ConfigObject func LoadConfiguration() { cfg := os.Getenv("SNMP_MQTT_CONF") log.Printf("cfg: %s", cfg) err := json.Unmarshal([]byte(cfg), &Config) if err != nil { log.Fatalf("Unable to parse configuration: %v", err) } }