37 lines
639 B
Go
37 lines
639 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
type Config struct {
|
|
Mode string
|
|
DatabaseUrl string
|
|
Port int
|
|
Ip string
|
|
AuthUsername string
|
|
AuthPassword string
|
|
AuthKey string
|
|
}
|
|
|
|
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"),
|
|
AuthKey: os.Getenv("SENSOR_AUTH_KEY"),
|
|
}
|
|
|
|
return &config
|
|
}
|