20 lines
411 B
Go
20 lines
411 B
Go
package smartconfig
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// EnvResolver resolves environment variables.
|
|
// Usage: ${ENV:VARIABLE_NAME}
|
|
type EnvResolver struct{}
|
|
|
|
// Resolve returns the value of the environment variable.
|
|
func (r *EnvResolver) Resolve(value string) (string, error) {
|
|
result := os.Getenv(value)
|
|
if result == "" {
|
|
return "", fmt.Errorf("environment variable %s not found", value)
|
|
}
|
|
return result, nil
|
|
}
|