/*
LoadEnv accepts a struct with the `green` field tag defined
for its fields and returns a map of environment variables with
defaults if specified. If a field is marked as required but
not found in the environment then LoadEnv panics.
*/
LoadEnv accepts a struct with the `green` field tag defined
for its fields and returns a map of environment variables with
defaults if specified. If a field is marked as required but
not found in the environment then LoadEnv panics.
/ * LoadEnv accepts a struct with the ` green ` field tag defined for its fields and returns a map of environment variables with defaults if specified . If a field is marked as required but not found in the environment then LoadEnv panics . * /
func LoadEnv(env Environment) (results map[string]string) {
	results, _ = LoadEnvFile(env.EnvFileLocation())
	fields := getStructFields(env)
	for _, field := range fields {
		ft := parseTag(field)
		val := os.Getenv(ft.EnvVarName)
		if len(val) == 0 {
			if ft.Required {
				panic(fmt.Sprintf("%s not found in environment", ft.EnvVarName))
			} else if ft.Default != "" {
				results[ft.EnvVarName] = ft.Default
			}
			continue
		}
		results[ft.EnvVarName] = val
	}
	return
}
func LoadEnv ( env Environment ) ( results map [ string ] string ) { results , _ = LoadEnvFile ( env . EnvFileLocation ( ) ) fields := getStructFields ( env ) for _ , field := range fields { ft := parseTag ( field ) val := os . Getenv ( ft . EnvVarName ) if len ( val ) == 0 { if ft . Required { panic ( fmt . Sprintf ( " " , ft . EnvVarName ) ) } else if ft . Default != " " { results [ ft . EnvVarName ] = ft . Default } continue } results [ ft . EnvVarName ] = val } return }
LoadEnv accepts a struct with the `green` field tag defined
for its fields and returns a map of environment variables with
defaults if specified.
LoadEnv accepts a struct with the ` green ` field tag defined for its fields and returns a map of environment variables with defaults if specified .