graphicek/server/config/config.go

35 lines
686 B
Go
Raw Normal View History

2022-08-13 23:33:50 +02:00
package config
import (
"os"
"strconv"
2022-08-13 23:33:50 +02:00
)
type Config struct {
Mode string `env:"GIN_MODE"`
DatabaseUrl string `env:"DATABASE_URL"`
Port int `env:"PORT"`
Ip string `env:"BIND_IP"`
AuthUsername string `env:"AUTH_USERNAME"`
AuthPassword string `env:"AUTH_PASSWORD"`
}
func LoadConfig() *Config {
port, err := strconv.Atoi(os.Getenv("PORT"))
2022-08-13 23:33:50 +02:00
if err != nil {
panic(err)
}
config := Config{
Mode: os.Getenv("GIN_MODE"),
DatabaseUrl: os.Getenv("DATABASE_URL"),
Port: port,
Ip: os.Getenv("BIND_IP"),
AuthUsername: os.Getenv("AUTH_USERNAME"),
AuthPassword: os.Getenv("AUTH_PASSWORD"),
2022-08-13 23:33:50 +02:00
}
return &config
}