You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
591 B
35 lines
591 B
package config
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"regexp"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func init() {
|
|
log.Println("* Loading Environment Configuration")
|
|
loadEnv()
|
|
}
|
|
|
|
func loadEnv() {
|
|
projectName := regexp.MustCompile(`^(.*` + "owltier.com" + `)`)
|
|
currentWorkDirectory, _ := os.Getwd()
|
|
rootPath := projectName.Find([]byte(currentWorkDirectory))
|
|
|
|
err := godotenv.Load(string(rootPath) + `/.env.local`)
|
|
|
|
if err != nil {
|
|
log.Println("* Error loading .env file")
|
|
}
|
|
}
|
|
|
|
func Environment() string {
|
|
return os.Getenv("ENVIRONMENT")
|
|
}
|
|
|
|
func ListenAddr() string {
|
|
return os.Getenv("LISTEN_ADDR")
|
|
}
|