35 lines
686 B
Go
35 lines
686 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
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"))
|
|
|
|
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"),
|
|
}
|
|
|
|
return &config
|
|
}
|