YiTao/config/config.go

32 lines
478 B
Go
Raw Permalink Normal View History

2024-11-09 14:59:27 +08:00
package config
import (
"fmt"
"log"
"github.com/caarlos0/env/v10"
"github.com/joho/godotenv"
)
type Config struct {
DB string `env:"DB"`
RDB string `env:"RDB"`
JwtSecret string `env:"JWT_SECRET"`
GeoipDB string `env:"GEOIP_DB"`
}
var conf = Config{}
func LoadConfig() Config {
godotenv.Load()
if err := env.Parse(&conf); err != nil {
log.Fatalf("%+v\n", err)
}
fmt.Printf("%+v\n", conf)
return conf
}
func GetConfig() Config {
return conf
}