You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
website/server/config/config.go

46 lines
645 B
Go

2 years ago
package config
import (
"git.phc.dm.unipi.it/phc/website/libs/sl"
"github.com/joho/godotenv"
)
var Slot = sl.NewSlot[Config]()
var TestingProductionConfig = Config{
Mode: "production",
Host: ":4000",
}
var TestingDevelopmentConfig = Config{
Mode: "development",
Host: ":4000",
}
type Config struct {
Mode string
Host string
}
func Load(l *sl.ServiceLocator) (Config, error) {
m, err := godotenv.Read(".env")
if err != nil {
return Config{}, err
}
var cfg Config
cfg.Mode = "production"
if v, ok := m["MODE"]; ok {
cfg.Mode = v
}
cfg.Host = ":4000"
if v, ok := m["HOST"]; ok {
cfg.Host = v
}
return cfg, nil
}