first commit
This commit is contained in:
34
env/enviroment.go
vendored
Normal file
34
env/enviroment.go
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
const (
|
||||
Env EnvKey = "ENV"
|
||||
PhotoDir EnvKey = "PHOTO_DIR"
|
||||
Host EnvKey = "HOST"
|
||||
Port EnvKey = "PORT"
|
||||
IntervalDefault EnvKey = "INTERVAL_DEFAULT"
|
||||
)
|
||||
|
||||
type EnvKey string
|
||||
|
||||
func Load(path string) error {
|
||||
if path == "" {
|
||||
path = ".env"
|
||||
}
|
||||
return godotenv.Load(path)
|
||||
}
|
||||
|
||||
func (key EnvKey) GetValue() string {
|
||||
return os.Getenv(string(key))
|
||||
}
|
||||
|
||||
func (key EnvKey) GetBoolValue() bool {
|
||||
value := strings.ToLower(os.Getenv(string(key)))
|
||||
return value == "true" || value == "1"
|
||||
}
|
||||
Reference in New Issue
Block a user