You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RoutingTableToWg/lib/environmentchecks/environmentchecks.go

28 lines
498 B
Go

package environmentchecks
import (
"os"
"fmt"
)
func HandleDefaults(envDefaults map[string]string){
for env, defaultValue := range envDefaults{
// Check if env is set
_, isSet := os.LookupEnv(env)
if(!isSet){
os.Setenv(env, defaultValue)
}
}
}
func HandleRequired(envRequired []string) error {
for _, env := range envRequired{
// Check if env is set
_, isSet := os.LookupEnv(env)
if(!isSet){
return fmt.Errorf("env '%s' required, but not set", env)
}
}
return nil
}