28 lines
608 B
Go
28 lines
608 B
Go
package application
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/sethvargo/go-envconfig"
|
|
)
|
|
|
|
func NewConfig() (Config, error) {
|
|
cfg := Config{}
|
|
|
|
if err := envconfig.Process(context.Background(), &cfg); err != nil {
|
|
return Config{}, fmt.Errorf("envconfig process: %w", err)
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|
|
|
|
type Config struct {
|
|
Devel bool `env:"DEVEL"`
|
|
HTTPPort uint `env:"HTTP_PORT, default=8001"`
|
|
HTTPHost string `env:"HTTP_HOST,default=0.0.0.0"`
|
|
DB string `env:"DB_DSN"`
|
|
UpdateInterval time.Duration `env:"UPDATE_INTERVAL,default=1s"`
|
|
}
|