mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-10-11 03:13:31 +00:00
22 lines
326 B
Go
22 lines
326 B
Go
package adapter
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func envOrFail(name string) (string, error) {
|
|
v, ok := os.LookupEnv(name)
|
|
if !ok || v == "" {
|
|
return "", fmt.Errorf("env %s is required", name)
|
|
}
|
|
return v, nil
|
|
}
|
|
|
|
func envOr(name, def string) string {
|
|
if v, ok := os.LookupEnv(name); ok && v != "" {
|
|
return v
|
|
}
|
|
return def
|
|
}
|