You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
611 B

2 years ago
package config
import (
"log"
"github.com/kelseyhightower/envconfig"
)
2 years ago
type dbConfig struct {
2 years ago
Host string `envconfig:"DB_HOST"`
Port int `envconfig:"DB_PORT"`
}
2 years ago
type appConfig struct {
2 years ago
Port int `envconfig:"APP_PORT"`
}
type authConfig struct {
SecretKey string `envconfig:"SECRET_KEY"`
}
2 years ago
type sentryConfig struct {
2 years ago
DSN string `envconfig:"SENTRY_DSN"`
}
2 years ago
// ...
type Config struct {
2 years ago
Db dbConfig
App appConfig
Auth authConfig
2 years ago
Sentry sentryConfig
2 years ago
}
func NewConfig() *Config {
c := Config{}
err := envconfig.Process("", &c)
if err != nil {
log.Fatal(err.Error())
}
return &c
}