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/services/config/config.go

36 lines
471 B
Go

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