43 lines
861 B
Go
43 lines
861 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
var Cfg Config
|
|
|
|
type Config struct {
|
|
Debug bool
|
|
ColorizedOutput bool
|
|
Host string
|
|
Port string
|
|
MariaDB MariaDB
|
|
}
|
|
|
|
type MariaDB struct {
|
|
Hostname string
|
|
Port string
|
|
Username string
|
|
Password string
|
|
DatabaseName string
|
|
}
|
|
|
|
func LoadConfig() {
|
|
godotenv.Load(".env")
|
|
|
|
Cfg = Config{
|
|
Debug: os.Getenv("DEBUG") == "true",
|
|
ColorizedOutput: os.Getenv("COLORIZED_OUTPUT") == "true",
|
|
Host: os.Getenv("HOST"),
|
|
Port: os.Getenv("PORT"),
|
|
MariaDB: MariaDB{
|
|
Hostname: os.Getenv("MARIADB_HOSTNAME"),
|
|
Port: os.Getenv("MARIADB_PORT"),
|
|
Username: os.Getenv("MARIADB_USERNAME"),
|
|
Password: os.Getenv("MARIADB_PASSWORD"),
|
|
DatabaseName: os.Getenv("MARIADB_DATABASE_NAME")},
|
|
}
|
|
}
|