35 lines
636 B
Go
35 lines
636 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
var Cfg Config
|
|
|
|
type Config struct {
|
|
Host string
|
|
Port string
|
|
LogFolder string
|
|
SSEServerEnabled bool
|
|
}
|
|
|
|
func LoadConfig() {
|
|
// used to determine server was startet in docker or not
|
|
if os.Getenv("DOCKER") == "" {
|
|
fmt.Println("Load env from file")
|
|
godotenv.Load(".env")
|
|
} else {
|
|
fmt.Println("Load env from system")
|
|
}
|
|
|
|
Cfg = Config{
|
|
Host: os.Getenv("HOST"),
|
|
Port: os.Getenv("PORT"),
|
|
LogFolder: os.Getenv("LOG_FOLDER"),
|
|
SSEServerEnabled: os.Getenv("SSE_SERVER_ENABLED") == "true",
|
|
}
|
|
}
|