Initial commit
This commit is contained in:
27
application/config.go
Normal file
27
application/config.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user