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.

38 lines
521 B

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