package common import ( "flag" "os" ) // For now just assume all values source from flags are strings var ( BrokerHost = flag.String("host", GetenvDefault("RUN_MQTT_HOST", "localhost"), "Hostname or IP address to an MQTT broker") BrokerPort = flag.String("port", GetenvDefault("RUN_MQTT_PORT", "1883"), "Port to an MQTT broker") ) // GetenvDefault retrieves an environment variable if set, or a provided default func GetenvDefault(key string, defaultValue string) string { val, exists := os.LookupEnv(key) if exists { return val } else { return defaultValue } }