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.
28 lines
366 B
28 lines
366 B
2 years ago
|
package config
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"github.com/kelseyhightower/envconfig"
|
||
|
)
|
||
|
|
||
|
type kafkaConfig struct {
|
||
|
Host string `envconfig:"KAFKA_HOST"`
|
||
|
Port int `envconfig:"KAFKA_PORT"`
|
||
|
}
|
||
|
|
||
|
// ...
|
||
|
type Config struct {
|
||
|
Kafka kafkaConfig
|
||
|
}
|
||
|
|
||
|
func NewConfig() *Config {
|
||
|
c := Config{}
|
||
|
err := envconfig.Process("", &c)
|
||
|
if err != nil {
|
||
|
log.Fatal(err.Error())
|
||
|
}
|
||
|
|
||
|
return &c
|
||
|
}
|